我在这里有这段代码:
<?php
error_reporting(E_ALL);
include 'DB.php';
$con = mysql_connect($host,$user,$pass)
or die("Error: ".mysql_error());
$dbs = mysql_select_db($databaseName, $con);
$name = $_POST['name'];
$date = date('Y-m-d');
$amount = $_POST['amount'];
$timPaid = $_POST['timPaid'];
$rennyPaid = $_POST['rennyPaid'];
$sql = "INSERT INTO $tableName (`name`, `date`, `amount`, `timpaid`, `rennypaid`)
VALUES ('$name', '$date', '$amount', '$timPaid', '$rennyPaid')";
$result = mysql_query($con, $sql)
or die("Error: ".mysql_error());
mysqli_close($con);
?>
DB.php 是我的数据库设置。我在页面加载时调用了一个查询,它可以很好地连接和提取数据,所以我知道这不是问题。我也没有收到任何错误。我在帖子上收到状态代码 200 OK。
这是ajax帖子:
var name = $('#name').val();
var amount = $('#amount').val();
var timPaid = $('#timPaid').val();
var rennyPaid = $('#rennyPaid').val();
var data = $('#newSubmissionForm').serialize();
$.ajax({
url: 'insert.php',
data: data,
type: 'post',
success: function()
{
window.location.href = '';
}
});
和我序列化有关系吗?
我希望这是足够的信息。谢谢!