Display username after login

-1

Then after long hours trying to display the login user name only I could not.

I think something is wrong just do not know where it is wrong xD

PHP:

<?php 
    require('config.php'); //INICIA A CONFIG PHP
    config_start(); 
    ?>

  <?php
    $email = $_POST['email'];
    $senha = $_POST['senha'];

    $query = @mysql_num_rows(mysql_query("SELECT * FROM cadastro WHERE email='$email' AND senha='$senha'"));
            if($query == 1){
            echo'<div style="background: rgb(36, 182, 36) none repeat scroll 0% 0%; color: white; padding: 4px; font-weight: bold;">Logado com Sucesso.</div>';
            echo "<script>setTimeout(window.location.href='http://pentazynetwork.pe.hu/biblioteca/plugins.php', 2);</script>";
            echo "<script>window.location.assign('".PATH."')</script>";
            echo "<script>document.getElementById('usuario_login_form').style.border='1px solid green'</script>";
            echo "<script>document.getElementById('senha_login_form').style.border='1px solid green'</script>";
                    $user_ip = $_SERVER['REMOTE_ADDR']; //Pega o IP do usuário
                    date_default_timezone_set('America/Sao_Paulo');
                    $last_login = date("d/m/Y | H:i:s");

                    mysql_query("UPDATE cadastro SET user_ip='$user_ip', last_login='$last_login' WHERE email='$email'");
                    $_SESSION['usuario'] = $email; // INICIA A SESSÃO
                    $_SESSION['senha'] = $senha; // INICIA A SESSÃO
                }else{
                    echo '<h5>USUARIO OU SENHA INVALIDOS!</h5>';
                    echo "<script>setTimeout(window.location.href='http://pentazynetwork.pe.hu/biblioteca/login.php', 2);</script>";
                }
    ?>

INDEX:

    
asked by anonymous 30.04.2017 / 06:15

1 answer

1

In your php, first of all put the line

session_start();

Example:

<?php 
    session_start(); 
    require('config.php'); //INICIA A CONFIG PHP
    config_start(); 
?>

And in your index too

<?php 
 session_start();
 ?>
<center>
  <br>
  <button class="w3-btn w3-green">20 novos plugins serão adicionados! Saiba mais.
    <?php echo $_SESSION['usuario']; ?>
  </button>
</center>

I hope I have helped.

    
30.04.2017 / 07:39