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? Link to comment https://forums.phpfreaks.com/topic/76116-solved-redirecting/ 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'); } ?> Link to comment https://forums.phpfreaks.com/topic/76116-solved-redirecting/#findComment-385244 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"); } Link to comment https://forums.phpfreaks.com/topic/76116-solved-redirecting/#findComment-385246 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. Link to comment https://forums.phpfreaks.com/topic/76116-solved-redirecting/#findComment-385526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.