Forum Moderators: coopster

Message Too Old, No Replies

Help PHP issue

Cant figure out code

         

dean0825

8:20 pm on Nov 19, 2008 (gmt 0)

10+ Year Member



Hi,
I'm fairly new to the php/mysql world. I need some help with my first assignment doing some php scripting and was going to see if there was a resource of scripts for this.

Here's what I need to do: Setup a simple zip code search form that will execute a script. A user enters the zip code and it redirects them to one of four pages which is associated with different zip codes (in the state of Georgia). If they enter a zip code that's not on the list, it would redirect them to a page that says something like "this zip code is not a part of the area....etc.". I know how to set up the form to execute the script, just don't know what the script itself should be. I'm assuming I won't need to use a DB, and that the zips would be in the script itself. Here is what i have so far:

Here is the form code to call up the script:

<form name="" method="post" action="redirect.php">
<input name="zip" type="text" id="zip" size="10">
<input type="submit" name="Submit" value="Go">
<br>
</form>

redirect.php is the script file of course. Contains th e following code:

<?php

$url = '';
switch ($zip) {
case "30002":
case "30012":
case "30013":
case "30014":
case "30015":
case "30016":
case "30017":
case "30018":
case "30021":
case "30025":
case "30030":
case "30031":
case "30032":
case "30033":
case "30034":
case "30035":
case "30036":
case "30037":
case "30038":
case "30039":
case "30047":
case "30048":
case "30052":
case "30054":
case "30055":
$url = '/redirect.php';
break;
default:
$url = '/login.php';
break;
}
header("Location:" . $url);

?>

But nothing happens ---- just goes to the redirect.php page

dean0825

10:01 pm on Nov 19, 2008 (gmt 0)

10+ Year Member



CAN SOME ONE HELP ME PLEASE

dreamcatcher

10:48 pm on Nov 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have register_globals OFF? In which case, this:

switch ($zip) {

should be:

switch ($_POST['zip']) {

and welcome to WebmasterWorld dean0825. :)

dc

dean0825

11:00 pm on Nov 19, 2008 (gmt 0)

10+ Year Member



well to be honest i don't understand what a register_globals off really means .. Im taking an advanced course and I was sick for a while and asked my friend that graduated to help me and I dont know too much .. what i can say is the form should take the zip code and pop up with a website .. take a look at how it should work.

[edited by: coopster at 11:28 pm (utc) on Nov. 19, 2008]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]

dean0825

11:43 pm on Nov 19, 2008 (gmt 0)

10+ Year Member



also thank you fir the warm welcome