Re:IF ELSEIF ELSE??

From: Date: Fri, 03 Aug 2001 23:04:14 +0000
Subject: Re:IF ELSEIF ELSE??
Groups: php.general 
Request: Send a blank email to php-general+get-61203@lists.php.net to get a copy of this message
First you should manage your code nicer so that it is easier to read and troubleshoot. Go through this to find my notes... if (!$HTTP_POST_VARS) { exit();} elseif ($HTTP_POST_VARS) { if (!$Age) { echo "Please enter your age.<br>\n"; } if Why would you use elseif above ? you are asking the full question in the first line if (!$HTTP_POST_VARS) { exit();} if it's NOT then why say elseif, it's else, it's either one or the other...that's one thing. so lets change it to this: if (!$HTTP_POST_VARS) { exit(); } else { if (!$Age) { echo "Please enter your age.<br>\n"; } if (!$Email) { echo "Please enter your email.<br>\n"; } if (!$State) { echo "Please enter your Location.<br>\n"; } (MARK) } else ( RIGHT HERE YOU DID NOT OPEN THE REST OF THE ELSE ) echo "Thanks for your submission."; ( RIGHT HERE YOU DID NOT CLSE THEN END OF THE CONDITION ) so the last lines replacing after (MARK) should look like this } else { echo "Thanks for your submission."; } As you can see keeping the code in this format makes it a lot easier to see what is being exectued within the condition, allows you to see the open & closes of the brackets, and should have easily let you see you were missing something. Hope that explains it....

« previous php.general (#61203) next »