Redirecting help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
peirates
Forum Newbie
Posts: 2
Joined: Thu Jul 05, 2007 5:55 am

Redirecting help

Post by peirates »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all. Quick question

I am currently using the following code:

Code: Select all

<?php 
if(  $something  ){ 
      Header("Location:  somewhere.php"); 
}  else  { 
     Header("Location:  somewhere1.php"); 
} 
?>

As you can see what it does is if one site is not available go to the other site(something like a software router)

What I want to do is when the first site(main server) is not available, to prompt the user that he is being redirected and then redirect him to site number 2(backup server)

with other words I want the same thing, but with an alert.

I tried everything i found on the net, but i keep getting errors.

Is what I want possible?

Thanks in advanced!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

peirates
Forum Newbie
Posts: 2
Joined: Thu Jul 05, 2007 5:55 am

Found it

Post by peirates »

I found what I wanted by experimenting with the code and help from the net

Code: Select all

<?php 
if(  $something  ){ 
      Header("Location:  somewhere.php"); 
}  else  { 
$text = "Due to server upgrade, you are being redirected to our backup server";
print "<script language=javascript> 
alert('$text'); 
</script>"; 
print "<script language=javascript>
window.location = ' somewhere1.php';
</script>";     
} 
?>
Thanks anyways[/syntax]
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

That method requires that JavaScript be enabled. Meta redirection does not.
Post Reply