Mysqli_fetch_array on locaweb, error logging in! [closed]

-2

Hello, I have the following code:

<?php   
session_start();

require_once('conecta.php');    
$email = sha1($_POST['email']);
$senha = $_POST['senha'];


$sql = "SELECT * FROM dados WHERE email = '$email' AND senha = '$senha'";
$objDb = new db();
$link = $objDb->conecta_mysql();    
$resultado = mysqli_query($link, $sql);

if ($resultado) {
    $dados = mysqli_fetch_array($resultado);
    if (isset($dados['email'])) {

        $_SESSION['email'] = $dados["email"];
        $_SESSION['nome'] = $dados["nome"];



        header('Location: indexVol.php');
    } else {
        header('Location: entrar.php?erro=1');


    }
} else {
    echo 'Erro na execução da consulta, favor entrar em contato com o admin do site';
}
?>

But when I try to log in, it goes straight to header('Location: entrar.php?erro=1'); , as if the database did not have the email and registered password, but it does. Does anyone have any idea what might be wrong? I know the code is not sure sql injection, but this is just a test for me to understand.

Note: The page is hosted in locaweb.com , I do not know if mysqli_fetch_array is available for use, because Xampp works normally!

    
asked by anonymous 09.01.2018 / 14:01

2 answers

1

The error at the beginning of the code can be generating the error, where you use SHA1 in the email, where the correct one and in the email:

wrong:

<?php   
 session_start();

 require_once('conecta.php');    
 $email = sha1($_POST['email']);
 $senha = $_POST['senha'];

Correct:

<?php   
 session_start();

 require_once('conecta.php');    
 $email = $_POST['email'];
 $senha = sha1($_POST['senha']);
    
09.01.2018 / 14:09
1

Modify these lines:

$email = $_POST['email'];
$senha = sha1($_POST['senha']);
    
09.01.2018 / 14:13