1
I have the Ragnarok database with the login table that has the userid (user) and user_pass (password) of the person. I am trying to get the system to enter this table and check if the field entered in the form matches what is in the database, however, php is always returning as if I had diigtado the incorrect field, and I am typing correctly...
Php code:
$query = "SELECT 'user_pass' FROM `login` WHERE userid = '".$_SESSION["userid"]."' ";
$resultado = mysqli_query($conexao, $query) or die(mysqli_error($conexao));
$campo = mysqli_fetch_array($resultado);
if($campo)
{
echo "<div class='alert alert-danger' role='alert'>Senha atual errada!</div>";
}
I don’t know what else to do..
Try it like this:
$user = $_SESSION["userid"]; $query = "SELECT user_pass FROM login WHERE userid = '$user'";
, remembering that when you use quotes, to add a variable the string is not necessary to break it; and complement with the rest of the password check, etc... is with you...– Rafael Withoeft
Do you want to make a login system? This query is searching for the user id and not login/password.
– Luis Henrique
Luis, password recovery system :x
– GGirotto
SOLVED! I used the code of @Rafaelwithoeft. It was going wrong because I used in the query SELECT 'user_pass' instead of SELECT user_pass. Thank you very much to everyone who helped! They want me to do a response with the correct code?
– GGirotto
@William would be interesting and mark it as certain later so that others who access can see how it was solved.
– Rafael Withoeft
Right! I’ll make it as soon as I get home @Rafael
– GGirotto