[thelist] undefined php variable
Tanner Burson
tanner at younet.okstate.edu
Thu Jul 31 13:56:40 CDT 2003
*This message was transferred with a trial version of CommuniGate(tm) Pro*
>Hmm. I see what you are getting after, but in some cases wouldn't
>this be a bad thing for me? Case in point, When this particular page
>loads it always grabs my $_POST values and places them into the form.
>If its your first time there, the form is empty because the values
>are empty (which is what I want).
>
>If I do the above, my form fields will all have "false" in them, or I
>have to put some logic before the field to say 'if its false, its
>blank'. (the page posts to itself)
>
>Also, if I want to check if my var has a value, can't I just do the
>
>if(isset($var)) if/when I need to check for its value?
>
>I'm no php guru, so just asking :)
>
>Tom
>
Yes using the example exactly as provided COULD cause the form to be
filled with false. Most likely php will treat the boolean false as a
null string so the boxes would be empty. To guarantee this mod the code
to say this :
$aDate = isset($_POST['postdate']) ? $_POST['postdate'] : "";
Now if the variable is not set $aDate is given a value of empty string so nothing would be written to your text boxes.
Tanner
More information about the thelist
mailing list