ncsunderland wrote:
I've tried several variations but I can't get any of them to execute.
If someone can tell me what's wrong with this I'd be grateful -
~~~~~~~~~~~~~~~~~
if ($stmt = $mysqli->prepare("UPDATE members (password, salt) VALUES (?,?) WHERE email = ?"))
{
$stmt->bind_param('sss', $newpassword,$random_salt,$email);
// Execute the prepared query.
$stmt->execute();
header("Location: ../secure/changepass.php?success=1'");
}
else {
header("Location: ../secure/changepass.php?passwordfailed=1'");
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks!!
You're using the wrong mysqli syntax to 'update' a database (see below, that should work). Obviously change the $newpassword, $random_salt and $email to whatever is getting that information. <?php // connect to database $mysqli = new mysqli('localhost' , 'username , 'password' , 'database_name'); $stmt = $mysqli->prepare("UPDATE members SET password = ?, salt = ? WHERE email = ?"); if($stmt = $mysqli->prepare("UPDATE members SET password = ?, salt = ? WHERE email = ?")) { $stmt->bind_param("sss", $newpassword, $random_salt, $email); // set parameters and execute $newpassword = "Pink"; $random_salt = "Elephant"; $email = "email_address.com"; $stmt->execute(); header("Location: ../secure/changepass.php?success=1'"); } else { header("Location: ../secure/changepass.php?passwordfailed=1'"); } ?>
... View more