我的更新脚本运行良好。但是我想做一个日志文件。我想要的是,当我更新数据时,它也会与 Table1 $ orderId 一起插入另一个表。
我的代码在这里运行良好。请帮助我如何从同一表格将此数据插入另一个表。期待专家的帮助。我是编码的初学者。
这是表单代码HTML
<div class="form-group">
<label for="due" class="col-sm-3 control-
label">Due Amount</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="due" name="due" disabled="true" />
</div>
</div>
<!--/form-group-->
<div class="form-group">
<label for="payAmount" class="col-sm-3
control-label">Pay Amount</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="payAmount" name="payAmount" />
</div>
</div>
<!--/form-group-->
<div class="form-group">
<label for="clientContact" class="col-sm-3
control-label">Payment Type</label>
<div class="col-sm-9">
<select class="form-control" name="paymentType" id="paymentType">
<option value="">~~SELECT~~</option>
<option value="1">Cheque</option>
<option value="2">Cash</option>
<option value="3">Credit Card</option>
</select>
</div>
</div>
<!--/form-group-->
<div class="form-group">
<label for="clientContact" class="col-sm-3
control-label">Payment Status</label>
<div class="col-sm-9">
<select class="form-control" name="paymentStatus" id="paymentStatus">
<option value="">~~SELECT~~</option>
<option value="1">Full Payment</option>
<option value="2">Advance Payment</option>
<option value="3">Credit Payment</option>
</select>
</div>
</div>
<!--/form-group-->
</div>
<?php
require_once 'core.php';
$valid['success'] = array('success' =>
false, 'messages' => array());
if($_POST) {
$orderId =
$_POST['orderId'];
$payAmount =
$_POST['payAmount'];
$paymentType =
$_POST['paymentType'];
$paymentStatus =
$_POST['paymentStatus'];
$paidAmount = $_POST['paidAmount'];
$grandTotal = $_POST['grandTotal'];
$updatePaidAmount = $payAmount +
$paidAmount;
$updateDue = $grandTotal -
$updatePaidAmount;
$sql = "UPDATE orders SET paid =
'$updatePaidAmount', due = '$updateDue',
payment_type = '$paymentType',
payment_status = '$paymentStatus' WHERE
order_id = {$orderId}";
if($connect->query($sql) === TRUE) {
$valid['success'] = true;
$valid['messages'] = "Successfully
Update";
} else {
$valid['success'] = false;
$valid['messages'] = "Error while
updating product info";
}
$connect->close();
echo json_encode($valid);
} // /if $_POST