Good morning,
I am doing a project in PHP ( login ) with database but it does not log me
This is my code:
<?php
$usuario = $_POST['nnpmbre'];
$pass = $_POST['npassword'];
if (empty($usuario) || empty($pass)) {
# code...
header("location: ../index.html");
exit();
}
mysqli_connect('localhost','root','12345678') or die ("Error al Conectar, Usuario o clave incorrectos" .mysqli_error());
mysqli_select_db('web_juegos') or die("Error, lo sentimos en estos momentos tenemos problemas en la base de datos porfavor intente mas tarde" .mysqli_error());
$result = mysqli_query("SELECT * from User0 ='".$usuario ."'");
if($row = mysqli_fetch_array($result)){
if($row['Password'] == $pass){
session_start();
$_SESSION['usuario'] = $usuario;
header("location: mensaje.php");
}else{
header("location: ../index.html");
exit();
}
}else{
header("location: ../index.html");
}
?>
Yes, I managed to log inif (empty($usuario) || empty($pass)) {
# code...
header("location: ../index.html");
exit();
}
That code reloaded the page for me when I started the session, I fixed it and I got this:
this is line 13:
mysqli_select_db('web_juegos') or die("Error, lo sentimos en estos momentos tenemos problemas en la base de datos porfavor intente mas tarde" .mysqli_error());
You have to put the Where in the query
In this case username is the name of the attribute in the mysql table.
I think your problem is in your query, having it as follows:
You would have to change it, you need the where inside it, being more or less like this: