Redirect options list not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
leegee3
Forum Newbie
Posts: 10
Joined: Thu Mar 29, 2007 7:28 am

Redirect options list not working

Post by leegee3 »

Again, I am a beginner at php and html so please go easy on me


I have a php file that has the following code...

Code: Select all

<?php

if($location != null)
{
	header("Location:$location");
	exit();
}

?>

<html><head><title> Redirect </title></head>
<body>

Please select a site:

<form action="<?php $PHP_SELF?>" method="post">

<select name="location">

<option value="http://www.google.com"> Google </option>
<option value="http://www.iii.co.uk"> Interactive Investor </option>
<option value="http://www.myspace.com"> Myspace </option>
<option value="http://www.facebook.com"> Facebook </option>

</select>
<input type="submit" name="submit" value="GO">

</form>
</body>
</html>
The page displays all of the options available in a dropdown list but when I click on the go button it does not take me to the appropriate page. Global Registers are turned off if that makes any difference!!
Any ideas???

Thanks Lee
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If register globals is off, $location will not be set automatically. You need to set it for PHP.

You also should not be using $PHP_SELF. Partly because register globals is off, but more importantly because it's a security hazard.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

repost...locked
Locked