Jump to content

Archived

This topic is now archived and is closed to further replies.

mkosmosports

Redirects based on URL variables...

Recommended Posts

Hello,

Does anyone know how to invoke a redirect to another html page (error page) based on the condition that a user selects certain variables in the URL. I know an if statement would have to be used, and I would use "if $variable =>.." so greater than or equal to. But I cant think of a way to invoke the redirect.....

Any suggestions?

Thanks a lot,
mkosmosports

Share this post


Link to post
Share on other sites
Hi,

You have to use the META tag for this

[code]<meta http-equiv="refresh" content="2;url=http://mypage/index2.php">[/code]

Share this post


Link to post
Share on other sites
Use the header() function...

[code]
<?php

if ($var == 1){
  header("Location: index.php");
}
elseif ($var == 2){
  header("Location: contact.php");
}
else {
  header("Location: error.php");
}
?>
[/code]

Regards
Huggie

Share this post


Link to post
Share on other sites
If you want to redirect a user use header, For example say you had a login script and then you checked for the logout variabled in the url If you find it you'll redirect the user to the logout page:
[code=php:0]if(isset($_GET['logout') && $_GET['logout'] == 'true')
{
    header("Location: logout.php");
}[/code]

Share this post


Link to post
Share on other sites
[quote author=shivabharat link=topic=110152.msg444786#msg444786 date=1159723004]
Hi,

You have to use the META tag for this

[code]<meta http-equiv="refresh" content="2;url=http://mypage/index2.php">[/code]
[/quote]

Not a good idea: http://www.w3.org/QA/Tips/reback

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.