i have a change password page on my website and when i test the page with a logged in user from my database i keep getting the error message “Your password could not be changed due to a system error. We apologize for any inconvenience.” from my echo statement
here is the code for my php page
---------PHP CODE-------------
[php]<?php # changepwd.php. This page allows a logged-in user to change their password.
// Set the page title and include the HTML header.
$page_title = ‘Change Password’;
require_once(’./includes/header.php’);
//Logged in
if(isset($_SESSION[‘user_id’]) && isset($_COOKIE[‘moviereviews’])){
//Handle the form.
if(isset($_POST[‘change’])){
//Check for a new password and match against the confirmed password.
$p = trim($_POST[‘password1’]); $p2 = trim($_POST[‘password2’]);
if(strlen($p) >=4 && !empty($p2)){
if($p != $p2){
$p = FALSE;
echo “
}
}else{
$p = FALSE;
echo “
}
//If every thing’s OK.
if($p){
//Escape any illegal MySql characters in the data
$p = mysqli_real_escape_string($dbc, $p);
$query = “UPDATE accounts SET password=SHA(’$p’) WHERE userID={$_SESSION[‘user_id’]}”;
$result = mysqli_query ($dbc, $query);
//If update was OK.
if($result){
//Load the logout page
$url = ‘./logout.php’;
//Delete the buffer.
ob_end_clean();
header(“Location: $url”);
//Quit the script.
exit();
//In case update was not OK.
}else{
echo “
}
//Failed the validation test.
}else{
echo “
}
//Close the database connection.
mysqli_close($dbc);
//End of the Submit conditional.
}
?>
Change Password
Must be between 4 and 20 characters long.
Note that you will be automatically logged out following a successful
password change and you will need to log back in using the new password.
<?php
}else{
echo “
}
require_once(’./includes/footer.php’);
?>[/php]
--------END OF PHP-----------