Login in restricted area

Asked

Viewed 37 times

0

I have a site with a login form inside a div, that clicked opens modal.

<a href='#' id='login-link'>Login</a>

I have some restricted areas on the site, and I would like to display the login form in case the user is not logged in, but I’m not getting.

if(!isset($_SESSION['usuario'])){
    //EXIBIR A DIV PARA LOGIN 
}

JS

$("#login-link").click(function(){
   $("#login-form").fadeIn(300);
   document.form1.loading.style.visibility = "hidden";
   $("#background-on-popup").css("opacity", "0.7");
   $("#background-on-popup").fadeIn(300);
   document.getElementById("username").value = "";
   document.getElementById("password").value = "";
   $("#username").focus();
}); 

1 answer

0

The code would look something like this:

<? if(!isset($_SESSION['usuario'])): ?>
<script>
$(document).ready(function() {
$("#login-link").click(function(){
   $("#login-form").fadeIn(300);
   document.form1.loading.style.visibility = "hidden";
   $("#background-on-popup").css("opacity", "0.7");
   $("#background-on-popup").fadeIn(300);
   document.getElementById("username").value = "";
   document.getElementById("password").value = "";
   $("#username").focus();
}); 
});
</script>
<? endif; ?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.