I am stuck on updating values from my SQL table. It works prefectly when instead of ...WHERE username = $username
I put an actual value from table ...WHERE username = 'Jane'
, but in other case it's just not updating values in the database at all. Here is part of my code:
if(isset($_POST['reset'])){
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "UPDATE users SET password ='$password' WHERE username = $username";
$stmtupdate = $db->prepare($sql);
$result = $stmtupdate->execute([$password]);
print_r($result);
if($result){
echo 'Successfully updated.';
}else{
echo 'There were errors while updating the data.';
}
}