CheeseDonkey Posted July 15, 2009 Share Posted July 15, 2009 I am pretty noobish at PHP. This is supposed to check whether or not a submitted address has all the fields filled in. If it does, it is supposed to echo which fields need filling in, and if it doesn't it's supposed to redirect to another page. This is what I got, but it doesn't work: <HTML> <BODY> <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $streetaddress = $_POST['streetaddress']; $streetaddress2 = $_POST['streetaddress2']; $city = $_POST['city']; $state = $_POST['state']; $zipcode = $_POST['zipcode']; $otherinfo = $_POST['otherinfo']; if ($firstname == "" or $lastname == "" or $streetaddress == "" or $city == "" or $zipcode == "") echo "<font color='red'>You forgot to fill out some fields. Click the back button to fix the mistake."; elseif ($firstname == "") echo "You must fill in the First Name.<br />"; elseif ($lastname == "") echo "You must fill in the Last Name.<br />"; elseif ($streetaddress == "") echo "You must fill in the Street Address.<br />"; elseif ($city == "") echo "You must fill in the City.<br />"; elseif ($zipcode == "") echo "You must fill in the Zip Code."; else header( 'Location: http://www.google.com' ) ; endif; ?> </BODY> </HTML> Can anyone assist? Why doesn't this work? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/166023-php-noob-needs-help/ Share on other sites More sharing options...
sKunKbad Posted July 15, 2009 Share Posted July 15, 2009 to start, all of those else ifs should just be ifs. Quote Link to comment https://forums.phpfreaks.com/topic/166023-php-noob-needs-help/#findComment-875596 Share on other sites More sharing options...
CheeseDonkey Posted July 15, 2009 Author Share Posted July 15, 2009 Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/166023-php-noob-needs-help/#findComment-875597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.