How to find the userclick?
Hi I am doing my project in PHP.In this when the user doesnt logged in and click the photo then it display the message please login.**Then **after login I wants, the user landing on the photopage..who clicked before login.How can I get the value of userclick and store it and how to redirect t开发者_Python百科hem to particular page?
It's not really a madder of what the user has clicked which anyway you don't have access to since it's on client side (apart using some ajax/javascript). You can know what URI/URL have been requested when you take the decision to redirect the user to the login page.
You have to stock in session ($_SESSION
) the requested page. In your login page and when the user manage to login redirect him to the page stocked in session.
for example:
where you take the decision to redirect the user to the login page
if($foobar){
$_SESSION['requested_page'] = $_SERVER['REQUEST_URI'];
header('Location: login.php');
die();
}
on the login page
if($loginOK){
if(isset($_SESSION['requested_page'])){
header('Location: ' . $_SESSION['requested_page']);
die();
}
header('Location: /index.php');
die();
}
This is usually handled with $_SERVER['HTTP_REFERER'] which will tell you where the user is coming from. Your log in page can then redirect back to it. (You don't need a session.)
精彩评论