My question is that I'm trying to do a password reset system.
[Current Password] [ New password ] [Change]
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> '
?>
I do not know the error, it is changing the password .. Plus it's kind of not half that confirming if the actual password actually is in the database.
Please, if anyone could help me, I would appreciate it.