Haraldur1234 Posted July 22, 2010 Share Posted July 22, 2010 Ok, so i am making a login script, so when a user puts in the details, it goes to checkuser.php and there it checks, how can i redirect him to the page after he logged in, like maybe news.php, and how can i redirect him to the login.php page if he dosnt have right info? Link to comment https://forums.phpfreaks.com/topic/208567-redirecting/ Share on other sites More sharing options...
Stooney Posted July 22, 2010 Share Posted July 22, 2010 header("Location: news.php"); This must be done before any output is ever sent (echo, print, etc). Link to comment https://forums.phpfreaks.com/topic/208567-redirecting/#findComment-1089700 Share on other sites More sharing options...
Haraldur1234 Posted July 22, 2010 Author Share Posted July 22, 2010 header("Location: news.php"); This must be done before any output is ever sent (echo, print, etc). I dont mean header, i mean it redirects you so your url is first lets say http://localhost/login.php, then i post and it goes to http://localhost/checkuser.php and then if its approved it goes to http://localhost/news.php! Link to comment https://forums.phpfreaks.com/topic/208567-redirecting/#findComment-1089706 Share on other sites More sharing options...
Pikachu2000 Posted July 22, 2010 Share Posted July 22, 2010 That's what header() is used for; to redirect. If that doesn't answer your question, chances are you need to rephrase the question to one that's more specific, and has more details. Link to comment https://forums.phpfreaks.com/topic/208567-redirecting/#findComment-1089717 Share on other sites More sharing options...
Stooney Posted July 22, 2010 Share Posted July 22, 2010 header("Location: news.php"); This must be done before any output is ever sent (echo, print, etc). I dont mean header, i mean it redirects you so your url is first lets say http://localhost/login.php, then i post and it goes to http://localhost/checkuser.php and then if its approved it goes to http://localhost/news.php! <?php //Login Stuff if($success){ //redirect them to news.php header("Location: news.php"); } else{ //bad username/password - redirect back to login form header("Location: login.php"); } Link to comment https://forums.phpfreaks.com/topic/208567-redirecting/#findComment-1089721 Share on other sites More sharing options...
Haraldur1234 Posted July 22, 2010 Author Share Posted July 22, 2010 header("Location: news.php"); This must be done before any output is ever sent (echo, print, etc). I dont mean header, i mean it redirects you so your url is first lets say http://localhost/login.php, then i post and it goes to http://localhost/checkuser.php and then if its approved it goes to http://localhost/news.php! <?php //Login Stuff if($success){ //redirect them to news.php header("Location: news.php"); } else{ //bad username/password - redirect back to login form header("Location: login.php"); } Thnx Link to comment https://forums.phpfreaks.com/topic/208567-redirecting/#findComment-1089723 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.