gpt4 book ai didi

数据库更新的 PHP 查询执行成功但值未在数据库表上更新

转载 作者:行者123 更新时间:2023-11-30 22:01:41 24 4
gpt4 key购买 nike

我正在通过从 html 表单中获取数据来更新客户详细信息。数据库的 PHP 查询正在执行,但更改的数据未反射(reflect)在我的数据库表中。

PHP代码:

从表单中获取数据的代码

$con = mysqli_connect("localhost","root","","ecommerce");
if(isset($_POST['savec']))
{
global $con;

$name=$_POST['name'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$passm=$_POST['password'];
$pass=md5($passm);
$cust_query="UPDATE er_customer SET customer_name='$name',customer_phone='$phone',customer_email='$email',customer_password='$pass' WHERE customer_id='c_id'";
$excecute=mysqli_query($con,$cust_query);

if($excecute)
{
echo "<script> alert('Account changes is successfull.') </script>";
}
}

表单代码:

>    <form method="post" class="registration-form"
> action="account_settings.php" id="form_login"
> enctype="multipart/form-data">
>
> <div class="form-group">
> <label>Name</label>
> <input class="form-control" name="name" type="text" value="<?php echo"$c_name"; ?>" required>
>
> </div>
>
> <div class="form-group">
> <label>Phone</label>
> <input class="form-control" name="phone" type="text" value="<?php echo"$c_phone"; ?>" required>
>
> </div>
>
>
> <div class="form-group">
> <label>Email</label>
> <input class="form-control" name="email" type="text" value="<?php echo"$c_email"; ?>" required>
>
> </div>
>
>
> <div class="form-group">
> <label>Password</label>
> <input class="form-control" name="password" type="text" value="" required>
> </div>
>
> </br>
>
> <div class="form-group">
>
> <input type="submit" class="col-sm-3 btn btn-success" name="savec" value="Save changes" align="center" />
>
> </div>
>
>
> </form>

最佳答案

尝试像这样更改您的更新查询:

$cust_query="UPDATE er_customer SET customer_name=$name,customer_phone=$phone,customer_email=$email,customer_password=$pass WHERE customer_id=$c_id";

通过调试所有变量值确保您获得正确

关于数据库更新的 PHP 查询执行成功但值未在数据库表上更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43161726/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com