0
My point is that I’m trying to make a password reset system.
[ Current password ] [ New password ] [ Swap ]
Good codes below
Settings.php
<?php
require_once('assets/system/core.php');
if (isset($_POST['password'])) {
$password = mysqli_query($db, "SELECT * FROM users WHERE password = 'password'");
if ($password->num_rows > 0) {
while($row = $password->fetch_assoc()) {
$userid = $row["id"];
}
}
elseif(mysqli_num_rows($password) == 0)
{
echo '<div id="alert-error">Senha está incorreta!</div>';
$passerror = true;
}
}
if (isset($_POST['npassword'])) {
$npassword = mysqli_query($db, "UPDATE users SET password='".$_POST['npassword']."' WHERE username='".$_SESSION['loginuser']."'");
{
echo '<div id="alert-green">Você foi registrado corretamente!</div>';
}
}
echo '
<div class="wrapper-me">
<div class="right-content" style="margin-left: 5px">
<div id="box" style="min-height: 400px; max-height: 1200px;">
<div id="blue-title" style="background: #27ae60; border: 1px solid #27ae60">
<h1 id="title-config">Alterar minha senha</h1>
<i style="color:#e0e0e0;" class="ion-edit"></i>
</div>
<div id="content-config" style="height: auto;">
<form action="" method="post" autocomplete="off">
<input type
<input type="password" name="password" placeholder="Senha atual" class="button-contn1"/>
<input type="password" name="npassword" placeholder="Nova senha" class="button-contn1"/>
<input type="submit" value="Continuar" class="button-contn">
</form>
</div> '
?>
He’s changing the password. But he’s not kind of confirming if the current password actually appears in the database.
Please, if anyone could help me, I’d appreciate it.
Just one question. where did this variable come from
$l_query
?– Flavio Misawa
So friend, I just edit this variable.. for password.. It was my mistake, but still the error.. it changes the password appears two messages " You changed your password correctly and the error together " but it is not checking I think.
– LeoS
First you’re leaving the fixed password comparison replaced by this
$password = mysqli_query($db, "SELECT * FROM users WHERE password = '".$_POST['password']"."'");
and then you arrow an error when the password is not found$passerror = true;
but you do not make any condition with it to give the error message and fail to do the update.– Flavio Misawa
All right, buddy, thanks a lot!
– LeoS