我有一个表单使用ajax将数据提交给mysql数据库,然后将表单发送到PayPal。jQuery ajax调用不会在按下按钮后更新mysql
但是,在提交后,如果我单击浏览器上的后退按钮,更改一些字段,然后再次提交表单,mysql数据不会更新,也不会创建新条目。
这里是我的Jquery:
$j(".submit").click(function() {
var hasError = false;
var order_id = $j('input[name="custom"]').val();
var order_amount = $j('input[name="amount"]').val();
var service_type = $j('input[name="item_name"]').val();
var order_to = $j('input[name="to"]').val();
var order_from = $j('input[name="from"]').val();
var order_message = $j('textarea#message').val();
if(hasError == false) {
var dataString = 'order_id='+ order_id + '&order_amount=' + order_amount + '&service_type=' + service_type + '&order_to=' + order_to + '&order_from=' + order_from + '&order_message=' + order_message;
$j.ajax({ type: "GET", cache: false, url: "/gc_process.php", data: dataString, success: function() { } });
} else {
return false;
}
});
这里是我的PHP脚本的样子:
<?php
// Make a MySQL Connection
include('dbconnect.php');
// Get data
$order_id = $_GET['order_id'];
$amount = $_GET['order_amount'];
$type = $_GET['service_type'];
$to = $_GET['order_to'];
$from = $_GET['order_from'];
$message = $_GET['order_message'];
// Insert a row of information into the table
mysql_query("REPLACE INTO gift_certificates (order_id, order_type, amount, order_to, order_from, order_message) VALUES('$order_id', '$type', '$amount', '$to', '$from', '$message')");
mysql_close();
?>
任何想法?
嘿,队友,你能看到使用Firebug控制台的电话吗? – 2010-12-06 01:26:23
这是实际的PHP脚本吗?听说过SQL注入? – Hamish 2010-12-06 01:26:42