Re: One last try at this!

From: Date: Wed, 17 Jan 2007 17:54:53 +0000
Subject: Re: One last try at this!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-247243@lists.php.net to get a copy of this message
Beauford wrote:
I hope I can explain this so I can get this figured out, 'cause if not I may just have to find an alternative to PHP. I can't be wasting 3 and 4 days on something as simple as this. Below are 3 validation routines. When I first enter the page 'Optional' is displayed for all of them as it should be, but when I click submit on the form without entering any data, the first one displays optional (which it should), but the 2nd and 3rd ones execute the elseif and the validation routine says there are invalid characters in the string. If nothing is entered in the form where is it getting a value???????????? It should never get to the elseif to start with if nothing is entered in the form. So how can I make a reliable check? if(empty($orgname)) { $formerror['orgname'] = "Optional"; } elseif($result = ValidateString($orgname, "2")) { $formerror['orgname'] = $result; } Take a little closer look at what you think are elseif statements below
You are missing the else part :(
if(empty($website)) { $formerror['website'] = "Optional"; } if($result = ValidateString($website, "2")) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = "Optional"; } if($result = ValidateString($event, "2")) { $formerror['event'] = $result; } Again, sorry to be a pain, but I just don't get it. Thanks


« previous php.general (#247243) next »