Php Script error?

Php Script error?

Posted by: shareme
Posted on: 2007-03-16 22:06:00

I wrote a simple php script and upload to "public html",but it fail
to run.
It should redirect www.yahoo.com
to When Visiting http://www.mydomain.com/jump.php?id=2

The source of php script is here:

<?PHP
if ($id == "1") {$link
= "http://www.aluriasoftware.com/";}
if ($id == "2") {$link
= "http://www.yahoo.com/";}
if ($id == "3") {$link
= "http://www.3.com/";}
if ($id == "4") {$link
= "http://www.4.com";}
if ($id == "5") {$link
= "http://www.5.com/";}
if ($id == "6") {$link
= "http://www.6.net/";}
if ($id == "7") {$link
= "http://www.7.com/";}
if ($id == "8") {$link
= "http://www.8.com/";}
if ($id == "9") {$link
= "http://www.9.com/";}
if ($id == "10") {$link
= "http://www.10.com/";}
if ($id == "11") {$link
= "http://www.11.com/";}
header("Location: $link");
exit();
?>

BTW:This script works well in another web hosting server,but failed in DH.

Re: Php Script error?

Posted by: silkrooster
Posted on: 2007-03-17 15:24:00

Instead of:
if ($id == "2") {$link
= "http://www.yahoo.com/";}

Try this:
if ($_GET['id'] == "2") {$link
= 'http://www.yahoo.com/';}
Silk

My website

Re: Php Script error?

Posted by: nathan823
Posted on: 2007-03-17 19:11:00

Is it better to add this code before the if-else?

if (!isset($_GET["id"])) $id="0";
else $id = trim(htmlspecialchars($_GET["id"]));

wink

Tags: php scriptmydomainscript error