Al,
This depends entirely on your browser actually, as it is the one sending
form variables back to the server in a POST request. Luckily, browsers
are very consistent with how they handle this. :)
Off the top of my head (I might be forgetting some form field types):
text fields - always set
drop downs - always set
radio buttons - will not be set if no radio box was selected
checkboxes - will not be set if no checkbox was checked
The best way to test this (always best to make sure rather than trust a
stranger on a mailing list, heh) would be to create a page with every
type of form field you can think of and submit it to a PHP page where
you loop through and output every variable in $_POST.
As for the functions you mention, is_null() checks to see if the
variable has a null value, which I believe is never the case for form
fields (someone correct me if I'm wrong). The function empty() is the
same check as ( == "") and will be true for text fields where the user
did not enter anything. The isset() function will let you know if a
variable exists at all. For the case of a single checkbox in a form
fields, the variable will be set if it was checked, and it will not be
set if the box was not checked.
Chris
Al Baker wrote:
>Hi,
>
>I've been wondering the behavior of browsers and POST submissions..
>basically I'd like to know the behavior of:
>is_null(), empty(), and isset().
>
>I've found that sometimes when an item is not filled out, the variable
>is still set on the subsequent page, like $_POST['var'] = "";
>
>What does everyone use to see if forms were submitted correctly?
>
>I built my own function:
>function form_exists($variable)
>{
> if (strlen($variable) < 1)
> {
> return false;
> } else {
> return true;
> }
>}
>
>It was the only apparent way I could know *for sure* that independent of
>the browser, I knew what the heck was being submitted.
>
>Thoughts?
>
>Thanks,
>Al
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php