Forum Moderators: coopster

Message Too Old, No Replies

redirect to url

         

scoobie

11:16 pm on May 7, 2005 (gmt 0)

10+ Year Member



Hi,

I running a php and mysql. i have a form that executes a switch statement and depending on the case i want to redirect to different URL's e.g. case 1: redirect to www.google.com
case 2: redirect to www.yahoo.com.

Sample code i tried:

switch($redirect)
{
case "1":
header("Location: [google.com...]
break;

case "2":
header("Location: [yahoo.com...]
break;
}

i have tested the switch using echo statements and it works i just can't get it to redirect automatically.

Can anybody help?

thanks in advanced

scoobie

IamStang

4:39 am on May 8, 2005 (gmt 0)

10+ Year Member



Not sure if this is what you are looking to do but
switch($redirect)
{
case "1":
google();
break;

case "2":
yahoo();
break;
}

function google(){
echo "<html><head><meta http-equiv='refresh' content='1; url=http://www.google.com'></head><body>Sending to google.</body></html>";
}

function yahoo(){
echo "<html><head><meta http-equiv='refresh' content='1; url=http://www.yahoo.com'></head><body>Sending to yahoo.</body></html>";
}

Might not be the best way but it should work. Hope it helps. If not, I tried.

Stormfx

5:52 pm on May 8, 2005 (gmt 0)

10+ Year Member



You can also use a refresh:

switch ($redirect) {
case 1:
header('Refresh: 5; URL=http://www.google.com');
echo 'Redirecting you to Google...';
break;
case 2:
header('Refresh: 5; URL=http://www.yahoo.com');
echo 'Redirecting you to Yahoo...';
break;
}

Where 5 is the delay in seconds.