I am checking if there are users in my BD through a form to enter the email and password. I check in a PHP file if the mail and the password exist in the database, but I get an error Undefined index: password and I do not know why.
HTML code:
<html>
<head>
<title>Introduce tu usuario</title>
<meta charset="UTF-8">
</head>
<body>
<h1>Introduce tu usuario:</h1>
<form method="get" action="comprobar.php">
<label for="correo">Correo:</label>
<input type="text" name="correo"><br/><br/>
<label for="password">Contraseña:</label>
<input type="password" name="password"><br/><br/>
<input type="submit">
</form>
</body>
</html>
Php code:
<?php
$correo=$_GET["correo"];
$password=$_GET["password"];
//Conexion con el servidor de base de datos
$conexion=mysqli_connect("localhost","root","","bdusuarios");
//Escribimos la consulta que queremos hacer
$consulta="SELECT * FROM usuarios";
//Ejecutamos la consulta
$resultado = mysqli_query($conexion,$consulta);
$swcorreo=0;
$swpassword=0;
//Vamos leyendo cada fila y comprobando los campos
while($fila = mysqli_fetch_array($resultado))
{
if(strcmp($fila["correo"], $correo) === 0)
{
$swcorreo=1;
}
if(strcmp($fila["password"], $password) === 0)
{
$swpassword=1;
}
}
//Mostramos si existe el usuario
if($swcorreo==1 && $swpassword==1)
{
echo "<h1>La cuenta existe</h1>";
}else
{
echo "<h1>La cuenta no existe</h1>";
}
?>