How to make a login system on the same page?

Asked

Viewed 722 times

1

Example:

The page of login and the page of usuário when you are logged in and in index, but I don’t 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;Perdeu sua senha? clique aqui</a></div>
    <div style="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;Recuperar meu email!</a></div>




<input style="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>

  • I don’t quite understand what your question is, what you can’t do specifically? You cannot show a different page for the status of being logged in or not being logged in, but on the same page?

  • by what I understand you want to show the login interface or the user interface on the same index? if yes you can use the Angularjs or jquery...

1 answer

4


Well from what I understand, your question is how to make the same page a different page for the situation of being logged in and another when it is not. First start with checking whether the user is logged in or not. Since you haven’t given a php example, here is 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. It remains to do what really matters, display the different part. Or you can choose to separate into files like: login.php and painel.php give a include, so:

    <?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 html in the middle, I prefer separate files because it makes it easier to understand and such, but with your example would be 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;Perdeu sua senha? clique aqui</a></div>
    <div style="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;Recuperar meu email!</a></div>




<input style="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
}
?>
  • You know what I’m thinking? Error: SQLSTATE[HY000] [2002] No connection to p to be made because the target machine actively refused them.

  • Your connection to the bank is all right?

  • @Roooliveira in this case is already another question. I suggest you use the site to ask another question. If that answer solved what you were asking, I suggest you mark it as useful.

Browser other questions tagged

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