更新代码在php和mysql中不起作用

llew8vvj  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(380)

大家好,请检查我写的代码,问题是它不会更新数据库中的数据,它只是重新加载,没有给出任何错误。这是我的update.php

if (isset($_POST['update']) && isset($_POST['update']) != "") {
    $name = $_POST['c_name'];
    $mobile = $_POST['c_mob'];
    $dDate = $_POST['d_date'];
    $frame = $_POST['frame'];
    $size = $_POST['size'];
    $lense = $_POST['lense'];
    $descr = $_POST['descr'];
    $paid = $_POST['paid'];
    $remains = $_POST['remains'];
    $refer = $_POST['c_refer'];
}
$setquery = "UPDATE `dep_sale` SET c_name='$name', c_mob='$mobile', d_date='$dDate', frame='$frame', size='$size', lense='$lense', descr='$descr',c_refer='$refer', paid='$paid', remains='$remains' WHERE id='".$_POST["id"]."'";
mysqli_query($link, $setquery); 
header("location: reports.php");

这是html

<form method="POST" action="update.php">
    <div class="row">
      <div class="col-lg-4 col-md-4">
        <input type="hidden" name="id" />
        <input type="text" class="form-control" value="<?php echo $row['c_name']; ?>" required id="c_name" name="c_name" placeholder="Name..."/>
      </div>
      <div class="col-lg-4 col-md-4">
        <input type="phone" class="form-control" value="<?php echo $row['c_mob']; ?>" required id="c_mob" name="c_mob" placeholder="Mobile..."/>
      </div>
      <div class="col-lg-4 col-md-4">
        <input type="text" class="form-control" value="<?php echo $row['d_date']; ?>" required id="d_date" name="d_date"  onfocus="(this.type='date')" placeholder="Delivery Date..."/>
      </div>
    </div>
    <br>
    <div class="row">
      <div class="col-lg-4 col-md-4">
        <input type="text" class="form-control" value="<?php echo $row['frame']; ?>" required id="frame" name="frame" placeholder="Frame..."/>
      </div>
      <div class="col-lg-4 col-md-4">
        <input type="text" class="form-control" value="<?php echo $row['size']; ?>" required id="size" name="size" placeholder="Size..."/>
      </div>
      <div class="col-lg-4 col-md-4">
        <input type="text" class="form-control" value="<?php echo $row['lense']; ?>" required id="lense" name="lense" placeholder="Lense..."/>
      </div>
    </div>
    <br>
</form>

连接没有问题,因为我正在完美地获取和插入数据。请帮助我。谢谢

7vux5j2d

7vux5j2d1#

要查看错误,请在第一行设置以下内容:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

你的假设是错的。试试这个:

if (isset($_POST['update']) && $_POST['update'] != "") {

或更短版本

if (!empty($_POST['update'])) {

希望这对你有帮助!

相关问题