i have this error When i try to login with a wrong password in the page the error is Parse error: syntax error, unexpected variable "$consulta" in C:\xampp\htdocs\PHPMYSQL\validar_usuario.php on line 13
This is the code, i hope that you can help me...
<?php
$usuario=$_POST['usuario'];
$clave=$_POST['clave'];
session_start();
$_SESSION['usuario']=$usuario;
include('db.php') /// the database is properly connected
$consulta= "SELECT*FROM usuarios WHERE usuario='$usuario' AND clave='$clave'";
$resultado-mysqli_query($conexion,$consulta);
$filas-mysqli_num_rows($resultado);
if($filas){
header("location:home.php");
}else{
?>
<?php
include("index.php");
?>
<h1 class= "bad">ERROR AUTENTIFICACION</h1>
<?php
}
mysqli_free_result($resultado);
mysqli_close($conexion);
CodePudding user response:
You forgot the >
here:
$resultado-mysqli_query($conexion,$consulta);
$filas-mysqli_num_rows($resultado);
It should be:
$resultado->mysqli_query($conexion,$consulta);
$filas->mysqli_num_rows($resultado);
CodePudding user response:
The line you refer to, the variable $consulta does not exist!!! as the error says... as identify there is semicolon missing.
include('db.php') /// the database is properly connected