Jump to content

PHP noob needs help


CheeseDonkey

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/166023-php-noob-needs-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.