更新查询运行,但SQL数据库中的字段未更新

时间:2018-12-28 02:43:51

标签: php mysql forms session md5

我有一个更新页面,其中包含电子邮件和密码的更新表单,我尝试了控制台日志记录以查看电子邮件和地址是否以邮寄方式发送,并且详细信息已发送到此页面,但数据仍未保留,有人可以告诉我为什么谢谢你!

<?php session_start(); ?>

    <?php

        //extract form values and assign to regular PHP variables
        $uemail=$_POST['email'];    
        $passW=$_POST['pass'];
        $upassword= md5($_POST['passW']);


    if(!isset($_SESSION['usermail'])) {
        header('Location: ../homepage.php');
    }

else{
include "connection.php";


$session=$_SESSION["useremail"];    

    $sql = "UPDATE users SET uemail = '$uemail', upassword = '$upassword' WHERE uemail = '$session'";

$_SESSION["useremail"]=$uemail; //setting new email in session

        header("Location:../homepage.php");
    }
?>

1 个答案:

答案 0 :(得分:-1)

尝试隐藏变量。

<?php session_start(); ?>

    <?php

        //extract form values and assign to regular PHP variables
        $uemail=$_POST['email'];    
        $passW=$_POST['pass'];
        $upassword= md5($_POST['passW']);


    if(!isset($_SESSION['usermail'])) {
        header('Location: ../homepage.php');
    }

else{
include "connection.php";


$session=$_SESSION["useremail"];    

    $sql = "UPDATE users SET uemail = '".$uemail."', upassword = '".$upassword."' WHERE uemail = '".$session."'";

$_SESSION["useremail"]=$uemail; //setting new email in session

        header("Location:../homepage.php");
    }
?>

并始终检查变量是否正确..始终查看您的代码。