2
Hello, I am making a login page but it is not redirecting the way I would like, using the header, instead when I click in it goes to the form action. The problem file is this one(postlogin.php):
<?php
session_start();
if(isset($_POST['login'])){
$email = $_POST['email'];
$senha = $_POST['senha'];
if(strlen($email) > 0 && strlen($senha) > 0) {
$conn = mysqli_connect("localhost", "root", "", "projeto_morada");
//Execução da instrução sql
$result = $conn->query("SELECT * from usuario where email = '$email' AND senha = '$senha';");
//$usuarios recebe a lista de usuários
$usuarios = mysqli_fetch_all($result);
$_SESSION['nome'] = $usuarios[0][1];
$_SESSION['email'] = $usuarios[0][2];
$_SESSION['senha'] = $usuarios[0][3];
header('Location: http://localhost/projeto_morada/index.php');
}
else {
echo "
<script>
alert('E-mail ou senha inválidos!')
location.href = 'index.php'
</script>
";
}
};
?>
And the form looks like this:
<form class="form" method="post" action="postlogin.php">
<label class="label-input" for="email">
<i class="far fa-envelope icon-modify"></i>
<input type="email" id="email" onkeyup="valida_login()" placeholder="E-mail">
</label>
<label class="label-input" for="senha">
<i class="fas fa-lock icon-modify"></i>
<input type="password" id="senha" onkeyup="valida_login()" placeholder="Senha">
</label>
<a class="password" href="#">Esqueceu sua senha?
</a>
<button class="btn btn-second" id="login">entre</button>
In case the first file would be the
postlogin.php
, correct?– Rfroes87
yes, that’s right
– Giovanna Collares