我遇到了一个问题。每次我去插入页面只是刷新和空白。我不知道问题在哪里,但我检查了我的SQL我使用的数据是相同的。所以我不知道问题出在哪里。
<form enctype="multipart/form-data" method="POST"> <tr>
<td> Generic Name:<input type="text" class="form-control" name = "gname"></td>
</tr>
<tr>
<td> Brand Name:<input type="text" class="form-control" name = "bname"></td>
</tr>
<tr>
<td> Quantity:<input type="number" min="0" class="form-control" name = "mqty"></td>
</tr>
<tr>
<td> Description:<input type="text" class="form-control" name = "mdesc"></td>
</tr>
<br>
<tr>
<td> <input type="submit" class="btn btn-info" name="add" Value="Add"></td>
</tr>
</form>
<?php
include "../../functions/connect.php";
error_reporting(0);
date_default_timezone_set('Singapore');
$date = date('m/d/Y h:i:s a', time());
?>
<?php
include "../../functions/connect.php";
extract($_POST);
if(isset($add)){
$sql = "INSERT INTO `tbl_meds`(`date`,`generic`,`brand`,`description`,`medqty`) VALUES ('$date','$gname','$bname','$mdesc','$mqty')";
$result = mysql_query($sql) or die("Verification Error: " . mysql_error());
}
?>
编辑:var_dump($_POST)
-
array(5) {
["gname"]=> string(11) "Paracetamol"
["bname"]=> string(8) "Biogesic"
["mqty"]=> string(3) "100"
["mdesc"]=> string(71) "The most prescribed Headache and Fever brand that's Effective and Safe."
["add"]=> string(4) "Save"
}
答案 0 :(得分:2)
if(isset($_POST["add"])){
这对你有用
您的表单有 POST 方法。所以在PHP方面你必须使用$_POST
全局变量来处理它。