Page 1 of 1
Auto?
Posted: Thu Jul 25, 2002 8:24 am
by Gavski
I want to build a page that automatically transfers me to other pages-eg
switch()
{
case 1:
go to a url;
break
case 2:
go to another url;
break
.........etc.
Problem:- I don't want to display links to the URL's, I want the page to automatically send me to the URL's
Surely there must be some PHP code that allows for this
Many thanks.
Posted: Thu Jul 25, 2002 8:50 am
by twigletmac
If the page automatically sends you to a particular page but you don't tell it which page to go to how does it know where to go?
I'm mildly confused by what you're trying to do. A little more detail wouldn't hurt - What are you trying to achieve and why are you trying to do it?
Mac
Posted: Thu Jul 25, 2002 9:35 am
by BDKR
Problem:- I don't want to display links to the URL's, I want the page to automatically send me to the URL's
If what you mean is that you don't want the user to see the url he or she is being shipped off too, I suspect PHP is
NOT going to get the job done. Additionally, most browsers show the user the url they are headin' for in the address bar. If you can use Javascript to affect this in someway, then you would have your answer eh? As a matter of fact, if you want to use some evil pop-up, you should be able to control whether or not it shows the address bar. I think that may be the direction you want to go.
Later on,
BDKR
Posted: Thu Jul 25, 2002 9:38 am
by RandomEngy
Code: Select all
switch( $variable ) {
case 1:
header("Location: page1.php");
exit;
break;
case 2:
header("Location: page2.php");
exit;
break;
case 3:
header("Location: page3.php");
exit;
break;
default:
break;
}
If the variable is equal to 1, then you'll get sent to page1.php, 2 and you're sent to page2.php, etc. Just remember you can't output anything to the page before you use the header() function. Also you probably don't need to put the exit and break statements in; I'm just paranoid.
Sorry
Posted: Fri Jul 26, 2002 4:41 am
by Gavski
Sory if this seemed vague, Randomengy's got it though, yes header() is just what I'm looking for.
I wanted to post a variable to the page and depending on the value of that variable, to be sent (automatically) to another page(of course that page would be given a specific URL in the switch() routine.
thanks for your replys
Posted: Fri Jul 26, 2002 5:20 am
by gnu2php
Don't know if this helps or not, but you could try a more concise approach:
Code: Select all
$pages = array('page1.php', 'page2.php', 'page3.php');
if (in_array($_GETї'page'], $pages))
header('Location: '.$_GETї'page']);