Reputation: 183
I need to have open pop-up with login form when user come from other site, and is redirected. Lets say user come from https:www.asd.com/profile but hes not logged in, so hes redirected to main page www.asd.com but with open popup login form.
My login form div
<div id="zaloguj">
<div class="zamknij"></div>
<div>
<div class="null"></div>
<div class="logincontent">
<div class="logindiv">
<div class="login-logo"></div>
<form action="/login/index.php" method="post">
<input type="text" name="username" size="20"/>
<input type="password" name="password" size="15"/>
<input type="submit" value="Zaloguj się" /> </form>
<div class="opis opis-forgot">
</div>
</div>
</div>
</div>
How i can check and perform some actions if the user was redirected?
Upvotes: 0
Views: 44
Reputation: 103
If I try to understand, you want to redirect to homepage if user not login right. If so, you can use javascript. I am not good with that but I will try to explain the logic: If you using PHP as backend, you can use SESSION/CACHE function to know if user loged in or not - on the profile page:
//check if user login or not
function status(){
if(userstatus==notLogedin){
window.location.replace = "http://www.asd.com?status=notlogin";
}
else{
//run page normally}
}
status();
on homepage, your js will be:
if(status==notlogin){ //you have to take parameter from URL
callPopupLogin(); //call your login form on pop up
}
else{
//run homepage normally
}
Upvotes: 0
Reputation: 3222
I'm not sure if JS can solve this, (might be with cookies, but I'm skeptic about that). I offer you a PHP solution:
<?PHP // set this in your main page
session_start();
$_SESSION['notRedirected'] = true;
?>
in your page you can get directed to you can check if session variable is set true:
<?PHP
session_start();
if( $_SESSION['notRedirected'] ) {
//...
}
?>
Upvotes: 1