I want to update users email from a form in my php page, but after i change the email, php delete it from database, any suggestion?
session_start();
require_once('database.php');
if (isset($_POST['modify-profile'])) {
$query = "UPDATE users SET email = '$_SESSION[m_email]' WHERE name ='$_SESSION[name]'";
$check = $pdo->prepare($query);
$check->execute();
header('Location: ../profile.php');
exit;
} else {
echo "ERROR";
}
<form action="php/modify-profile.php" method="POST">
<input type="email" placeholder="Email:" name="m_email">
<input type="submit" name="modify-profile">
</form>
CodePudding user response:
your question is not clear . did you set $_SESSION[m_email] variable before ? if you didn't , you have to use $_POST['m_email'] instead of that .