pedjasmek Posted November 5, 2007 Share Posted November 5, 2007 How can I redirect a user to a certain page depending on some condition?(If it is true go to page 1 else go to page 2).Is it possible? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 5, 2007 Share Posted November 5, 2007 Something like this... <?php if (1st condition){ header('Location: page.php'); } else if (2nd condition){ header('Location: page.php'); } else { header('Location: page.php'); } ?> Quote Link to comment Share on other sites More sharing options...
mitt Posted November 5, 2007 Share Posted November 5, 2007 You can use header("Location:") to accomplish this. if(condition == true) { header("Location: page_if_true.php"); } else { header("Location: page_if_false.php"); } Quote Link to comment Share on other sites More sharing options...
pedjasmek Posted November 6, 2007 Author Share Posted November 6, 2007 I've learned later that there is cure for that.It's output buffering.Use ob_start() function at the very beginning of the page(before any header was sent) and ob_clean() in the script where ever there is need for it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.