Page 1 of 1

Redirect options list not working

Posted: Mon May 07, 2007 3:05 pm
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

Posted: Tue May 08, 2007 9:02 am
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.

Posted: Tue May 08, 2007 9:04 am
by JayBird
repost...locked