嗨大家可以请检查我写的代码,问题是它不会更新数据库中的数据,它只是重新加载而不会给出任何错误。 这是我的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>
连接没有问题,因为我正在完美地提取和插入数据。请帮助我们。谢谢
答案 0 :(得分:0)
要查看错误,请在第一行设置以下内容:
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'])) {
希望这有助于你!