I am fairly new to PHP, as I mostly skilled in the front end aspects of the web, but I have to create a form for a House Maid service in which you enter your zip code, and it would determine if you’re within their service area. I thought about using Google’s map API, but fear that would over complicate the service area of about 25 miles(i.e. Half of “smalltownville” is serviced while the other half isn’t wouldn’t pan out well due to the word of mouth aspect of the industry). So I thought it would be best to keep it to the zip codes. I can’t seem to get this to work, although I am pretty sure the syntax is correct. Any help would be greatly appreciated.
Here is the code I have so far:
<form method="post" action="zip-code.php">
Zip Code: <input name="zip" type="text" /><br />
<input type="submit" />
</form>
and the PHP:
<?php
$zip = $_REQUEST['zipcode'] ;
$zipcode=("z");
if ($z=="1")
echo "You are serviced by branch 1!";
elseif ($z=="2")
echo "You are serviced by branch 2!";
else
echo "You are not serviced.";
?>
Thanks in advance!
1 Answer