Mysqli查询确实提交了表单

时间:2016-02-07 08:10:48

标签: php mysql

请建议以下代码是否适合在MYSQL中进行更新。当我尝试通过表单提交时,程序就会死亡。

这是我的代码

<?php
include('sdg_connect.php');

$securedmember=$_POST['securedmember'];
$modifiedtime=$_POST['modifiedtime'];
$url=$_POST['url'];
$member_id=$_GET['member_id'];
$member_name=$_POST['member_name'];
$member_mob=$_POST['member_mob'];
$member_emailid=$_POST['member_emailid'];
$member_age=$_POST['member_age'];
$member_weight=$_POST['member_weight'];
$member_sex=$_POST['member_sex'];
$member_address1=$_POST['member_address1'];
$member_address2=$_POST['member_address2'];
$member_occupation=$_POST['member_occupation'];
$member_joindate=$_POST['member_joindate'];
$member_gymplan=$_POST['member_gymplan'];
$member_feespaid=$_POST['member_feespaid'];
$member_reference=$_POST['member_reference'];
$sdg_cheque_no=$_POST['sdg_cheque_no'];
$member_feesdue=$_POST['member_feesdue'];
$sdg_trainer=$_POST['sdg_trainer'];
$sdg_time=$_POST['sdg_time'];
$sdg_expire_date=$_POST['sdg_expire_date'];
if (isset($_POST['member_info_save']))  {
    $sdg_member_query = "UPDATE sdg_members SET member_name='$member_name', member_mob='$member_mob', member_emailid='$member_emailid', member_age='$member_age', member_weight='$member_weight', member_sex='$member_sex', member_address1='$member_address1', member_address2='$member_address2', member_occupation='$member_occupation', member_joindate='$member_joindate', member_gymplan='$member_gymplan', member_feespaid='$member_feespaid', member_reference='$member_reference', sdg_cheque_no='$sdg_cheque_no', member_feesdue='$member_feesdue', sdg_trainer='$sdg_trainer', sdg_time='$sdg_time', sdg_expire_date='$sdg_expire_date', modifiedtime='$modifiedtime' WHERE member_id='$member_id'";


        mysqli_query($conn, $sdg_member_query) or die('Error occured while saving members data <a href='.$url.'>Go Back</a>');

        session_start();
        $_SESSION['msg']="<div class=\"col-md-10\" style=\"padding: 5px 0px;font-size: 12px;border-radius: 5px;background: #EEEEEE;position: fixed;bottom: 75px;text-align: center;left: 8%;box-shadow: 1px 1px 3px rgba(179, 176, 176, 0.67);\">Member details has been successfully update</div>";
         header('location:'.$url.'');

    }
    else    {
        header('location:'.$url.'');
    }
?>

如果上面的代码是正确的,请告诉我

1 个答案:

答案 0 :(得分:0)

检查表中每列的数据类型。对于整数类型的列,您不需要使用'(单引号)。例如,如果member_id字段是整数,那么您可以将代码写为

WHERE member_id=$member_id

没有'符号。

对所有整数变量执行此操作。