0
Good morning! I have a panel in php and the same is not connecting to DB. Any password I enter, password or incorrect user.
Follow the code snippet that makes the connection:
<?php
session_start();
$usuariot = $_POST['usuario'];
$senhat = $_POST['senha'];
include "conexao.php";
$result = mysqli_query("SELECT * FROM usuario WHERE login='$usuariot' AND senha='$senhat' LIMIT 1");
$resultado = mysqli_fetch_assoc($result);
if(empty($resultado)){
$_SESSION['loginErro'] = "Usuário ou senha inválido";
header ("Location: login.php");
}
?>
And below the excerpt of the code that connects to the database:
<?php
$conectar = mysqli_connect("localhost","root","") or die ("Erro na conexão");
mysqli_select_db($conectar, "painel_admin");
?>
Thanks in advance!
Remember I mentioned yesterday in the other question? no
mysqli_query()
you need to pass the connection as first argument always.– rray
You mean like: $result = mysqli_query("localhost","SELECT * FROM user WHERE login='$usuariot' AND password='$senhat' LIMIT 1");
– Pedro Ribeiro
Thus:
mysqli_query($conectar, "SELECT * FROM usu....").
– rray
Thanks rray! It worked
– Pedro Ribeiro