Wednesday, 7 August 2013

redirect back to previous page php

redirect back to previous page php

I am trying to redirect a user back to the page he/she were after
successful login but it is not working right for me.
The problem is that instead of redirecting to the previous page it
redirects to account.php..
The main page... index.php
<?php
$_SESSION['page'] = 'index.php';
?>
And here is login php..
if(isset($_SESSION["page"]) && is_object($_SESSION["page"])) //check if
session exists
{
//Redirect a user to the previous page
header("Location:".$_SESSION['page']);
}
else{header("Location:account.php");die();}

No comments:

Post a Comment