prepare($sql)) { $stmt->bindParam(":name", $name, PDO::PARAM_STR); $stmt->bindParam(":email", $email, PDO::PARAM_STR); $stmt->bindParam(":id", $user_id, PDO::PARAM_INT); if (!empty($new_password)) { $stmt->bindParam(":password", $hashed_password, PDO::PARAM_STR); } if ($stmt->execute()) { $_SESSION['success_message'] = "Your profile has been updated successfully."; } else { $_SESSION['error_message'] = "Oops! Something went wrong. Please try again later."; } unset($stmt); } unset($pdo); header("location: profile.php"); exit; } ?>