0
I’m starting programming with PHP, Since My Login screen is not Receiving the User and password, this and the code of my Verification page, you can see what’s wrong please.
<?php
include('conexao.php');
if (empty($_POST['usuario']) || empty($_POST['senha'])){
header('Location: index.php');
exit();
}
$usuario = mysqli_real_escape_string($conexao, $_POST['usuario']);
$senha = mysqli_real_escape_string($conexao, $_POST['senha']);
$query = "SELECT * from cad.usuario where usuario = '{$usuario}' and senha = '{$senha}'";
$result = mysqli_query($conexao, $query);
$row = mysqli_num_rows($result);
if($row > 0){
$_SESSION['usuario'] = $usuario;
header('Location: principal.php');
exit();
}else{
$_SESSION['não_autenticado'] = true;
header('Location: index.php');
exit();
}
What error is happening? Enter the first if?
– Benilson
the error is that it does not log in, when I inform the user and password that is registered in the Database, it goes back to login screen and stays like this, I already cleared the browser cache more
– LUIZ AUGUSTO SURF
session_start is missing, sessions only work with session_start
– Guilherme Nascimento
In case you’re entering the first
if (empty($_POST['usuario']) || empty($_POST['senha'])){
the data may be arriving via get$_GET
by forgetting the definition of the method="post" attribute in the tag<form>
.– Benilson