我的方法$ _POST在其他形式下也可以正常工作,但在这里我的$ _POST无法正常工作。 这是我的表格
<h3 class="page-title">Medicine Inventory: Add Stock</h3>
<form method="POST" action="PHP/action_insertaddstock.php" accept-charset="UTF-8">
<div class="panel panel-default">
<div class="panel-heading">
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-12 form-group">
<label for="medicine_id" class="control-label">Medicine ID (Required) :</label>
<select class="form-control select2" required="" id="medicine_id" name="medicine_id">
<option value="" selected="selected">-- Please select --</option>
<?php foreach($medicines as $val) : ?>
<option value="<?php echo $val['id']; ?>"><?php echo $val['name']; ?></option>
<?php endforeach; ?>
</select>
<p class="help-block"></p>
</div>
</div>
<div class="row">
<div class="col-xs-12 form-group">
<label for="qty" class="control-label">Quantity (Required) :</label>
<input class="form-control" placeholder="" required="" name="qty" type="number" id="qty">
<p class="help-block"></p>
</div>
</div>
<div class="row">
<div class="col-xs-12 form-group">
<label for="xdate" class="control-label">Expiry Date (Required) :</label>
<input class="form-control " placeholder="" required="" name="xdate" id="xdate">
<p class="help-block"></p>
</div>
</div>
</div>
</div>
<button class="btn btn-success" type="submit" name="submit" >Save</button>
</form>
我的动作在这里
<?php
if (isset($_POST['submit'])) {
include_once('CONFIG/config.php');
include_once('CONFIG/db.php');
$Med_id = $_POST['medicine_id'];
$Qty = $_POST['qty'];
$Xdate = $_POST['xdate'];
$Timestamp = date("Y-m-d H:i:s");
if(empty($Med_id) || empty($Qty) || empty($Xdate) || empty($Timestamp)){
header("Location: ../added_stock.php?add=empty");
exit();
}else{
$sql = "INSERT INTO medicines_addeds (qty, xdate, created_at,
med_id) VALUES ('$Qty', '$Xdate', '$Timestamp', '$Med_id')";
mysqli_query($conn, $sql);
header("Location: ../added_stock.php?add=success");
exit();
}
} else {
header("Location: ../MIAdd_medicine.php");
exit();
}
查询工作正常,因为我尝试将值放入变量中,并将其插入到数据库中,但是当我尝试$ _POST时,它什么也无法成功运行,但是我的数据库为空。请帮助我
表结构在这里
1 idPrimary int(11) No None AUTO_INCREMENT
2 qty int(11) Yes NULL
3 xdate date Yes NULL
4 created_at timestamp Yes NULL
5 edited_at timestamp Yes NULL
6 deleted_at timestamp Yes NULL
7 med_id int(11) Yes NULL
答案 0 :(得分:1)
使用xp解析您的xdate
state = this.createAppState({
take: 10,
group: []
});