It is a record in PHP, the problem is in the function that checks if a person is registered or not, always shows the data in Null.
if (isset($_REQUEST['entrar'])) {
session_start();
$conexion = new Conexion();
$email = $_REQUEST['email'];
$pass = $_REQUEST['pass'];
$datosPersona = $conexion->comprobarPersona($email, $pass);
if ($datosPersona != null) {
$p = new Persona($datosPersona[0], $datosPersona[1], $datosPersona[2], $datosPersona[3]);
$_SESSION["resultado"] = $p;
header('Location: bienvenido.php');
} else {
$_SESSION["resultado"] = "Usuario o password incorrectos";
header('Location: index.php');
}
If we leave when checking Conexion () we find this:
function comprobarPersona($email, $pass) {
$stmt = $this->conexion->prepare("SELECT * FROM personas WHERE email='" . $email . " AND pass='" . $pass . "'");
$stmt->execute();
$usuario = null;
while ($row = $stmt->fetch()) {
$usuario = array($row[0], $row[1], $row[2], $row[3]);
}
$stmt->close();
return $usuario;
I've checked everything and I do not know what's wrong. It always stays in Null $ user. Thanks in advance.