Show button if logged in / out if not

0

I want to show the "panel" button if the user is logged in, and if I do not want to show the login button, is it possible?

Follow my code ...

<?php

if(isset($_SESSION['usuario'])){
    "echo "<a href="logado.php" class="btn btn-success btn-large">Painel</a>" . "<br>";
}else{

    echo "<a href="login.php" class="btn btn-success btn-large">Login/Entrar</a>" . "<br>";
}



?>
    
asked by anonymous 07.02.2018 / 07:10

1 answer

0

Friend, a simple solution would be just using Jquery and CSS, I'll leave an example below for you.

$('#btn-post').click(function(){

if($('#name').val()  == "Jorge" && $('#mail').val() == "123"){
   $('p').text('Login efetuado,Botão painel visível!') 
   $('#btn-painel').show();
}
else{
  $('#btn-painel').hide();
  $('p').text('Login incorreto, botão não disponível!') 
}
})
#btn-painel{
   display:none;
}
    <div>
        <label for="name">Nome:</label>
        <input type="text" id="name" />
    </div>
    <div>
        <label for="mail">E-mail:</label>
        <input type="email" id="mail" />
    </div>
    <div>
        <label for="msg">Mensagem:</label>
        <textarea id="msg"></textarea>
    </div>
    <div class="button">
        <button id="btn-post">Clique para testar!</button>
        <button id="btn-painel">Painel</button>
        <p></p>
    </div>

<script
  src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

Totest,enterinthefieldname"Jorge" and in E-mail="123", just to simulate a login, if the data is this, the button will be visible, otherwise it will be hidden. >     

07.02.2018 / 12:29