[Ajuda] [PHP verificar] Verificar senha para login
#2

Nгo precisa de verificar.php, use esse script abaixo em MySQLi, altere o salt no hash e os dados de sua database:
PHP код:
<html>  
    <head>  
        <title> SAMP </title>
    </head> 
    
    <body>
        <?php
        $conexao 
mysqli_connect("host""user""password""database");
        
        
session_start(); 
        
        if(isset(
$_SESSION['Nome']))
        {
            echo 
"Vocк jб estб logado como <strong>$_SESSION[Nome]</strong>!";
            exit();
        } 
        if(isset(
$_POST['usr']) && isset($_POST['psw']) && isset($_POST['botao'])) 
        { 
            
$usuario mysqli_real_escape_string($conexao$_POST['usr']);  
            
$senha strtoupper(hash("sha256"$_POST['psw'] . $HASH_SENHA));  
             
            
$query mysqli_query($conexao"SELECT UserID, Username, Senha FROM accounts WHERE Username='$usuario' AND Senha='$senha' LIMIT 1");  
            
            if(
mysqli_num_rows($query) < 1)  
            {
                
//usuбrio ou senha invбlidos 
                
$loginFail 1;
            }
            else 
            { 
                
//login efetuado 
                
$dados mysqli_fetch_assoc($query);  
                
$_SESSION['ID'] = $dados['UserID'];  
                
$_SESSION['Nome'] = $dados['Username'];
                
$_SESSION['Senha'] = $dados['Senha']; 
                
header("location: login.php");   
            }  
        }
        
?> 
        <center>  
            <h2>Login</h2>
            <?php if(isset($loginFail)) echo "ERRO: Usuбrio ou senha invбlidos!"?>
            <form role="form" method="post" action="">   
                <div class="container_login">
                    <label><b>Username</b></label>  
                    <input type="text" placeholder="Enter Username" name="usr">  
                    <br>  
                    <label><b>Password</b></label>  
                    <input type="password" placeholder="Enter Password" name="psw">  
                    <br>
                    <button type="submit" name="botao">Login</button>  
                </div>
            </form>
        </center> 
    </body>  
</html>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)