Login System - HTTP ERROR 500

Asked

Viewed 84 times

0

I am making a login system, but when submitting the data it from HTTP ERROR 500. I tried to change the code anyway but this error continues. I am using 000webhost to test how the site is getting, will this server that does not support the codes I used or there is something wrong in the code and I am not noticing?

<?php
session_start();
include_once("conecta.php");
if ((isset($_POST['email'])) && (isset($_POST['senha']))) {
    $email = mysqli_real_escape_string($conn, $_POST['email']);
    $senha = mysqli_real_escape_string($conn, $_POST['senha']);
    $senha - md5($senha);

    $sql = "SELECT * FROM voluntarios WHERE email = '$email' and senha = '$senha'";
    $result = mysqli_query($conn, $sql);
    $resultado = mysqli_fetch_assoc($result);

    if (empty($resultado)) {
        $_SESSION['loginErro'] = "E-mail e/ou senha inválidos!"
        header("Location: entrar.php");
    } elseif (!empty($resultado)) {
        header("Location: indexVol.php");
    } else{
        $_SESSION['loginErro'] = "E-mail e/ou senha inválidos!"
        header("Location: entrar.php");
    }



} else {
    $_SESSION['loginErro'] = "E-mail ou senha inválidos!";
    header("Location: entrar.php");
}
?>

Connection to the database:

<?php
$conn=mysqli_connect("localhost", "arthur", "senha","banco");

if (!$conn) {
    die("Falha na conexão: " . mysql_connect_error());
} else {
    //echo "Conexão realizada com sucesso";
}
?>
  • 2

    How does this line work? "$password - md5($password);"

  • @Wictorchaves This line is to encrypt the password, but this - it’s wrong, it’s supposed to be =, I’ll see if this was the error even!

  • 1

    The semicolons are missing (;) when you set the sessions. And you used the function mysql_connect_error instead of mysqli_connect_error.

  • @Andersoncarloswoss I changed this, not give more error, but it does not go to indexVol.php page it just says that the email and password are wrong, but it is the same of the database

  • Then check the value of $resultado making var_dump($resultado).

  • @Andersoncarloswoss I put but nothing appeared.

Show 1 more comment
No answers

Browser other questions tagged

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