Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Email deleted after database table updates in PHP

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>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 .

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading