PDO php change password error

Hello,
I have an issue with my handle changing password php codes. I’m a beginner so hopefully someone could help out.
This is my HTML code

<?php include '../header.php'; ?>
Old Password :
New Password :
 

and this is my php code
require_once ("…/databaseStorage/dbFunction.php");

$passwordChange = $db->prepare(“SELECT * FROM admin WHERE password = AES_ENCRYPT(?, ‘st2220’)”);
$passwordChange->execute([$_POST[‘Oldpassword’]]);
if ($passwordChange->rowCount() == 0) {
echo ‘Error!’;
header(‘Location: …/adminChangePassword.php’);
}else{
$changePassword = $passwordChange->fetch();
$_SESSION[‘recordid’] = $changePassword[‘recordid’];
$correctPassword = $db->prepare(“UPDATE users SET users password = AES_ENCRYPT(?,‘st2220’)”);
$correctPassword->execute([$_POST[‘newpassword’]]);
}
echo ‘Success!’;
header(‘Location: …/index.php’);

It cant seem to validate an error of changing password or changing password. any help?
Thanks a lot!

you’re selecting from admin but updating users? am i missing something?

yes i have noted that i updated it in the wrong table, i have managed to fix it alr! thanks a loads for the help!!

Sponsor our Newsletter | Privacy Policy | Terms of Service