How to make a login system on the same page? [closed]

1

Example:

The page of login and the page of usuário when it is logged in and in the same index , but I do not know how to do this.

<!--comeco login
    <html><head></head><body><h1 class="top">PAINEL DE USUÁRIO</h1>
      <ul id="left_menu">
      <table width="266" border="0" align="center" cellpadding="0" cellspacing="0">
    <tbody><tr>
      <td width="66" height="42" align="center" valign="middle">
      <div style="margin-left:10px;">
      <input value="" style="width:90%;" placeholder="digite seu login..." required="" name="login" id="rnewpassword" maxlength="12" type="text" autocomplete="off">
      <input value="" style="width:90%;" placeholder="digite sua senha..." required="" name="password" id="rnewpassword" maxlength="12" type="password" autocomplete="off">
    </div>
    <div style="position:absolute;margin-left:10px; margin-top:5px;"><a href="#" onclick="new Ajax.Updater('container', 'template/php/iNext_rSenha.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="font-size:11px;"><img src="http://www.cabalxnew.com.br/template/images/bullet.png">&nbsp;Perdeusuasenha?cliqueaqui</a></div><divstyle="position:absolute;margin-left:10px; margin-top:20px;"><a href="#" onclick="new Ajax.Updater('container', 'template/php/recuperarmail.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="font-size:11px;"><img src="http://www.cabalxnew.com.br/template/images/bullet.png">&nbsp;Recuperarmeuemail!</a></div><inputstyle="float: right; margin-bottom:7px;" onclick="new Ajax.Updater('container', 'template/php/validar.php', {method: 'post', asynchronous:true, evalScripts:true, parameters:Form.serialize(document.logar)}); carregando(); mover();" type="button" value="Logar" name="submit" id="submit" class="submit">


  </td>
</tr><tr>
</tr></tbody></table>
  </ul> 
	
	
</body></html>
final login -->
<html>
<head></head>

<body>
  <h1 class="top">Gerenciamento de Conta</h1>
  <div style="padding-left: 15px;">





    Bem-vindo: <b style="color:#67BEFD;font-weight:normal;">romario</b>.
    <br>Cash: <span id="coins_cash" name="coins_cash">0</span> 
    <img src="template/images/pc.png" style="margin: 0 0 -1px 0" border="0" height="10">
    <br>T-Point: <span id="coins_cash" name="coins_cash">10</span> 
    <img src="template/images/pc2.png" style="margin: 0 0 -1px 0" border="0" height="10">
    <br>Conta está: <span id="coins_cash" name="coins_cash"><font style="color:#8A0808;">Offline</font></span>
    <br>
    <script>
      $j(document).ready(function() {

        getTempo(0);

      });
    </script>
    Tempo de Jogo: <span id="coins_cash" name="coins_cash"><strong class="tempodejogo"></strong></span>
    <br>
    <img src="template/images/sidebar-box-head.png" style="position:absolute; margin-top:-9px; margin-left:-8px;">
    <br>
  </div>
  <ul id="left_menu">
    <li>
      <p>
        <img src="template/images/bullet.png"><span id="nationwarx3"></span> 
        <a onclick="new Ajax.Updater('container', 'template/php/USER/p-user.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="cursor:pointer;">Painel do usuario</a>
      </p>
    </li>

    <li>
      <p>
        <img src="template/images/bullet.png"><span id="nationwarx3"></span> 
        <a onclick="new Ajax.Updater('container', 'template/php/USER/p-admin.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="cursor:pointer;">Painel do administrador</a>
      </p>
    </li>
    <li>
      <p>
        <img src="template/images/bullet.png"><span id="nationwarx3"></span> 
        <a onclick="new Ajax.Updater('container', 'template/php/USER/p-mod.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="cursor:pointer;">Painel do Moderador</a>
      </p>
    </li>
  </ul>



  <div class="natal-chapeu-buttom-deslogar"></div>
  <input style="float: right; margin-right:5px;" value="Deslogar" tabindex="3" name="login_out" onclick="new Ajax.Updater('container', 'template/php/validar.php?sair=sair', {method: 'get', asynchronous:true, evalScripts:true}); carregando(); mover();" type="button">
  <div style="height:2px;"></div>
  <br>
  <br>
</body>

</html>
    
asked by anonymous 15.12.2016 / 01:40

1 answer

4

Well from what I understand, your question is how to make a different page on the same page for the situation to be logged in and another when it is not. First start with verification whether or not the user is logged in. Since you did not give an example of php, here's an example.

<?php 
//vefificação se o usuario esta logado ou não
if(isset($_SESSION['usuario'] && !empty($_SESSION['usuario'])){

//aqui dentro o usuário esta logado

}
else{

//aqui dentro o usuário não esta logado

}
?>

And here it is almost done. You have to do what really matters, display the different part. Or you can choose to separate files like: login.php and painel.php give an include, like this:

    <?php 
//vefificação se o usuario esta logado ou não
if(isset($_SESSION['usuario'] && !empty($_SESSION['usuario'])){

//aqui dentro o usuário esta logado
include('painel.php');
}
else{

//aqui dentro o usuário não esta logado
include('login.php');
}
?>

Or you can do it directly, opening and closing php and putting the html in the middle, I prefer in separate files because it makes it easier to understand and such, but with your example it would look like this.

    <?php 
//vefificação se o usuario esta logado ou não
if(isset($_SESSION['usuario'] && !empty($_SESSION['usuario'])){

//aqui dentro o usuário esta logado
?>
    <html>
<head></head>

<body>
  <h1 class="top">Gerenciamento de Conta</h1>
  <div style="padding-left: 15px;">





    Bem-vindo: <b style="color:#67BEFD;font-weight:normal;">romario</b>.
    <br>Cash: <span id="coins_cash" name="coins_cash">0</span> 
    <img src="template/images/pc.png" style="margin: 0 0 -1px 0" border="0" height="10">
    <br>T-Point: <span id="coins_cash" name="coins_cash">10</span> 
    <img src="template/images/pc2.png" style="margin: 0 0 -1px 0" border="0" height="10">
    <br>Conta está: <span id="coins_cash" name="coins_cash"><font style="color:#8A0808;">Offline</font></span>
    <br>
    <script>
      $j(document).ready(function() {

        getTempo(0);

      });
    </script>
    Tempo de Jogo: <span id="coins_cash" name="coins_cash"><strong class="tempodejogo"></strong></span>
    <br>
    <img src="template/images/sidebar-box-head.png" style="position:absolute; margin-top:-9px; margin-left:-8px;">
    <br>
  </div>
  <ul id="left_menu">
    <li>
      <p>
        <img src="template/images/bullet.png"><span id="nationwarx3"></span> 
        <a onclick="new Ajax.Updater('container', 'template/php/USER/p-user.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="cursor:pointer;">Painel do usuario</a>
      </p>
    </li>

    <li>
      <p>
        <img src="template/images/bullet.png"><span id="nationwarx3"></span> 
        <a onclick="new Ajax.Updater('container', 'template/php/USER/p-admin.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="cursor:pointer;">Painel do administrador</a>
      </p>
    </li>
    <li>
      <p>
        <img src="template/images/bullet.png"><span id="nationwarx3"></span> 
        <a onclick="new Ajax.Updater('container', 'template/php/USER/p-mod.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="cursor:pointer;">Painel do Moderador</a>
      </p>
    </li>
  </ul>



  <div class="natal-chapeu-buttom-deslogar"></div>
  <input style="float: right; margin-right:5px;" value="Deslogar" tabindex="3" name="login_out" onclick="new Ajax.Updater('container', 'template/php/validar.php?sair=sair', {method: 'get', asynchronous:true, evalScripts:true}); carregando(); mover();" type="button">
  <div style="height:2px;"></div>
  <br>
  <br>
</body>

</html>

<?php
}
else{
//aqui dentro o usuário não esta logado
?>
    <html><head></head><body><h1 class="top">PAINEL DE USUÁRIO</h1>
      <ul id="left_menu">
      <table width="266" border="0" align="center" cellpadding="0" cellspacing="0">
    <tbody><tr>
      <td width="66" height="42" align="center" valign="middle">
      <div style="margin-left:10px;">
      <input value="" style="width:90%;" placeholder="digite seu login..." required="" name="login" id="rnewpassword" maxlength="12" type="text" autocomplete="off">
      <input value="" style="width:90%;" placeholder="digite sua senha..." required="" name="password" id="rnewpassword" maxlength="12" type="password" autocomplete="off">
    </div>
    <div style="position:absolute;margin-left:10px; margin-top:5px;"><a href="#" onclick="new Ajax.Updater('container', 'template/php/iNext_rSenha.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="font-size:11px;"><img src="http://www.cabalxnew.com.br/template/images/bullet.png">&nbsp;Perdeusuasenha?cliqueaqui</a></div><divstyle="position:absolute;margin-left:10px; margin-top:20px;"><a href="#" onclick="new Ajax.Updater('container', 'template/php/recuperarmail.php', {method: 'get', asynchronous:true, evalScripts:true}); esperar('container'); carregando(); mover();" style="font-size:11px;"><img src="http://www.cabalxnew.com.br/template/images/bullet.png">&nbsp;Recuperarmeuemail!</a></div><inputstyle="float: right; margin-bottom:7px;" onclick="new Ajax.Updater('container', 'template/php/validar.php', {method: 'post', asynchronous:true, evalScripts:true, parameters:Form.serialize(document.logar)}); carregando(); mover();" type="button" value="Logar" name="submit" id="submit" class="submit">


  </td>
</tr><tr>
</tr></tbody></table>
  </ul> 


</body></html>


<?php
}
?>
    
15.12.2016 / 02:45