Login in restricted area

0

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

<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 can not.

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();
}); 
    
asked by anonymous 18.03.2016 / 17:35

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; ?>
    
19.03.2016 / 11:54