Notice: Undefined variable: user in C:\xampp\img\htdocs\Formularios\validar.php on line 19
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\img\htdocs\Formularios\validar.php on line 19
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\img\htdocs\Formularios\validar.php on line 21
Estos son los código:
<!DOCTYPE html>
<html>
<head>
<head>
<title>Validando...</title>
<meta charset="utf-8">
</head>
</head>
<body>
<?php
if(isset($_POST['login'])){
$usuario = $_POST['user'];
$pw = $_POST['pw'];
$sesion_login = true;
$log = mysqli_query("SELECT * FROM tbusuario WHERE user='$user' AND pw='$pw'");
$link = mysqli_connect("127.0.0.1","root","","dbpazysalvo") or die("<h2>No se encuentra el servidor</h2>");
if (mysqli_num_rows($log)>0) {
$row = mysqli_fetch_array($log);
$_SESSION["user"] = $row['usuario'];
echo 'Iniciando sesión para '.$_SESSION['user'].' <p>';
}
else{
echo '<script> alert("Usuario o contraseña incorrectos.");</script>';
//echo '<script> window.location="index.php"; </script>';
}
}
?>
</body>
</html>
------------------------------------------------------------------------------------------------------------------------------------------------------
index.php
-----------------------
<html>
<head>
<title>login Admin</title>
<meta charset="utf-8">
</head>
<body>
<br>
<br>
<center><img src="logo.png" align="center" width="161" height="64" /></center>
<center><p><h1></h1></p></center>
<center><p><h1></h1></p></center>
<br>
<br>
<form method="POST" action="validar.php">
<center><p><h1></h1></p></center>
<center> <label for="nombre">Nombre de Usuario:</label><br></center>
<center><input type="text" class="form-control" name="user" autocomplete="off" required><br><br>
<center> <label for="contra">Contraseña:</label><br></center>
<input type="password" class="form-control" name="pw" autocomplete="off" required><br><br>
<input type="submit" class="btn btn-success" name="login" value="Entrar"></center>
</form>
</body>
</html>
Agradezco la ayuda de quien me la pueda brindar.