Page 1 of 1

Redirecting help

Posted: Thu Jul 05, 2007 6:21 am
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]

Posted: Thu Jul 05, 2007 6:28 am
by volka

Found it

Posted: Sat Jul 07, 2007 5:25 am
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]

Posted: Sat Jul 07, 2007 11:09 am
by superdezign
That method requires that JavaScript be enabled. Meta redirection does not.