thankqwerty Posted October 2, 2008 Share Posted October 2, 2008 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 More sharing options...
realjumper Posted October 2, 2008 Share Posted October 2, 2008 <?php if ($a>$b) { echo "<script>document.location.href='A.php'</script>"; } else{ echo "<script>document.location.href='B.php'</script>"; } ?> Link to comment https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/#findComment-655238 Share on other sites More sharing options...
dezkit Posted October 2, 2008 Share Posted October 2, 2008 <?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"); } Link to comment https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/#findComment-655248 Share on other sites More sharing options...
realjumper Posted October 2, 2008 Share Posted October 2, 2008 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 Link to comment https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/#findComment-655258 Share on other sites More sharing options...
xtopolis Posted October 2, 2008 Share Posted October 2, 2008 <?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) Link to comment https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/#findComment-655259 Share on other sites More sharing options...
MasterACE14 Posted October 2, 2008 Share Posted October 2, 2008 why not use header(); ? <?php if ($a>$b) header("Location: A.php"); else header("Location: B.php"); ?> EDIT: I didn't see you already posted this suggestion dezkit , my bad... Link to comment https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/#findComment-655291 Share on other sites More sharing options...
JasonLewis Posted October 2, 2008 Share Posted October 2, 2008 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. Link to comment https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/#findComment-655294 Share on other sites More sharing options...
dezkit Posted October 2, 2008 Share Posted October 2, 2008 echo '<META HTTP-EQUIV="refresh" CONTENT="0;A.php" />'; else echo '<META HTTP-EQUIV="refresh" CONTENT="0;B.php" />'; This script should be used thankqwerty, now hit topic solved. Link to comment https://forums.phpfreaks.com/topic/126693-solved-problem-with-redirecting/#findComment-655302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.