Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.