I am trying to create a online system wherein each u开发者_如何学运维ser logs in with a unique id and password. I have implemented the code to verify the password but how do i redirect to a new(home) page after a successful password verification?
You need to output a header to redirect them:
header('Location: newpage.php');
Keep in mind that you should verify your user is authenticated on every page, otherwise people can access the urls directly.
Assuming the home url is at home.php
header("Location: home.php");
after you check that user is authenticated you should write this line
header('location: home.php');
by this line of code you will redirect to home.php page..
As other guys said, you should use header() function, but you need to specify the full URL for Location, not only URI. Source: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html #14.30 Like so:
header('Location: http://site.com/home.php');
And make sure you not sending anything to output before header() call.
精彩评论