prepare($sql)){ // Bind variables to the prepared statement as parameters $stmt->bindParam(":password", $param_password, PDO::PARAM_STR); $stmt->bindParam(":id", $param_id, PDO::PARAM_INT); // Set parameters $param_password = password_hash($new_password, PASSWORD_DEFAULT); $param_id = $_SESSION["id"]; // Attempt to execute the prepared statement if($stmt->execute()){ // Password updated successfully. Destroy the session, and redirect to login page session_destroy(); header("location: index.php"); exit(); } else{ echo "Oops! Something went wrong. Please try again later."; } // Close statement unset($stmt); } } // Close connection unset($pdo); } ?>
Please fill out this form to reset your password.