When trying to make a query in mysql from php to start a session I get the following error: Warning: mysqli_fetch_array () expects parameter 1 to be mysqli_result, boolean given in C: \ xampp \ htdocs \ procesologin.php on line 10 after the query I have an if mysqli_fetch_array () and then an else, I always go to the else, do not enter the if, right there is the error. could you tell me how to fix it this is the html code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
</head>
<body>
<form role="form" action="procesologin.php" method="POST">
<input class="form-control" placeholder="Usuario" name="usuario" type="text" autofocus>
<input class="form-control" placeholder="Contraseña" name="contrasena" type="password" value="">
<input type="submit" name="submit" class="btn btn-lg btn-primary btn-block" value="Ingresar">
</body>
</html>
this is the connection to the database:
<?php
$server = "localhost";
$user = "root";
$pass = "";
$db = "prueba";
$tabla_db1 = "usuario";
$conexion = new mysqli($server,$user,$pass,$db);
?>
and this is the process:
<?php
session_start();
include("conexionprueba.php");
$user = $_POST['usuario'];
$password = $_POST['contrasena'];
$resultado = mysqli_query($conexion,"SELECT * FROM usuarios WHERE user = $user AND password = $password");
if ($consulta = mysqli_fetch_array($resultado)){
echo "sesion exitosa";}
else{
echo "sesion no exitosa";}
?>
Thanks