Jump to content

[SOLVED] problem with redirecting


thankqwerty

Recommended Posts

Hello all, I want to redirect to two possible pages depending on some condition so i have :

<?php

if ($a>$b) echo  "<META HTTP-EQUIV="refresh" CONTENT="0; A.php">";

else echo  "<META HTTP-EQUIV="refresh" CONTENT="0; B.php">";

?>

 

but the out is simply

<META HTTP-EQUIV="refresh" CONTENT="1; A.php"> 

where the page is not redirected.

 

Is there any other to handle this?

Link to comment
https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/
Share on other sites


<?php

if ($a>$b)
{
echo "<script>document.location.href='A.php'</script>";
}
else{
echo "<script>document.location.href='B.php'</script>";
}

?>

 

 

what if the browser doesn't let javascript be passed?

I would suggest this script

if ($a>$b){
header("Location: A.php");
} else {
header("Location: B.php");
}

 

 

what if the browser doesn't let javascript be passed?

I would suggest this script

if ($a>$b){
header("Location: A.php");
} else {
header("Location: B.php");
}

 

 

What  if he's already sent headers?

 

The number of people who know how to turn off JavaScript, let alone the number of people who actually do turn it off, is tiny

<?php
if ($a>$b) echo  "<META HTTP-EQUIV="refresh" CONTENT="0; A.php">";

else echo  "<META HTTP-EQUIV="refresh" CONTENT="0; B.php">";

?>

 

but the out is simply

<META HTTP-EQUIV="refresh" CONTENT="1; A.php"> 

 

--> should be:

echo  '<META HTTP-EQUIV="refresh" CONTENT="0;A.php" />';
else echo  '<META HTTP-EQUIV="refresh" CONTENT="0;B.php" />';

You don't change the < to <... etc when you want the code to be parsed (not displayed, but run)

 

 

what if the browser doesn't let javascript be passed?

I would suggest this script

if ($a>$b){
header("Location: A.php");
} else {
header("Location: B.php");
}

 

 

What  if he's already sent headers?

 

The number of people who know how to turn off JavaScript, let alone the number of people who actually do turn it off, is tiny

 

If the code is structured properly then the headers already being sent should not be a problem. A website should be able to run with JavaScript enabled or disabled, regardless.

Archived

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

×
×
  • Create New...

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.