Click to See Complete Forum and Search --> : The Horror Part II: PHP and forms


Daot Lagorille
08-13-2003, 12:53 PM
*stumbles in, dirty and bruised*

Am trying to pass values from form to php results page. Works fine, except for the checkboxes:

If I check a box, fine, that value gets passed and database results appear accordingly. HOWEVER:

if checkbox is not checked, no emplty value is passed - nothing. So I don't get any results at all, though I should be getting all records (unrestricted by condition passed if checkbox would have been checked)

I think this may be a foible particular to checkboxes - anyone know away around this?

*collapses*

Khalid Ali
08-14-2003, 07:21 PM
if you have coded your php script properly and sql correct,then the code should take care of it that if there is not checkboxes selected then fetch all results...to me its a flaw in your program.
However,if you must see some value in the check box fields then thats totally a different story...:D

Quasibobo
08-15-2003, 12:57 PM
I ussually do this:

if (!isset($_POST['checkbox']))
{
$value=x;
}
else
{
$value=y;
}

Da Warriah
08-15-2003, 01:28 PM
something like this might work a bit better:

if (empty($_POST['checkbox']))
{
$value=x;
}
else
{
$value=y;
}

i believe thats what i used for some radio buttons of mine that were screwing up...

pyro
08-16-2003, 07:59 PM
There is an important difference between the two:

isset() will tell you if the variable exists, which empty() will tell you if the variable contains a non-empty or non-zero value. For instance, $var = ""; $var = " "; or $var = "0" are all considered empty...

Daot Lagorille
08-18-2003, 08:31 AM
The is the greatest forum.

I have ever seen.

Thank you all.

For your help.

*feels faith in cyber-humanity restored*