嗨,我有一个三个表单和一个提交按钮,它位于所有三个表单之外,我想使用 php 将所有三个表单的值保存到 mysql 数据库中,任何人都可以帮助我展示如何完成我正在使用在这里提交表单值的 jquery 是我的 jquery
<script>
$(document).ready(function() {
$("#submit").click(function(event) {
alert('send 1st form');
$.post($("#form1").attr("action"), $("#form1").serialize(),
function() {
alert('send 2nd form');
$.post($("#form2").attr("action"), $("#form2").serialize(),
function() {
alert('send 3th form');
$.post($("#form3").attr("action"), $("#form3").serialize(),
function() {
alert('Both forms submitted');
});
});
});
event.preventDefault();
});
});
</script>
因为我在此之前发布了一个查询,这帮助我提交了表单,现在我想将这些值保存到我的数据库中
她是我的 php 代码
if(isset($_POST["submit"])){
$gen1 = mysql_query("SELECT MAX(accode) AS maxcode FROM quotmain LIMIT 0,1 ") or die(mysql_error());
if (mysql_num_rows($gen1) > 0) {
$vvouch = mysql_fetch_assoc($gen1);
$qvouch = $vvouch["maxcode"] + 1;
} else{
$qvouch = '1';
}
$a = 1;
$vouchdt = mydt($_POST["vouchdt"]);
$name = $_POST["cmbparty"];
$refno = $_POST["refno"];
$attn = $_POST["attn"];
$subj = $_POST["subject"];
$msg = $_POST["messsage"];
$rem = $_POST["rem"];
$count = $_POST["items"];
$h = $_POST["h"];
$status = $_POST["cmbstatus"];
mysql_query("DELETE FROM quotdtl WHERE vouchno='$qvouch'") or die(mysql_error());
for ($i = 1; $i <= $count; $i++) {
$ord = $_POST['ord_' . $i];
$srno = $_POST['srno_' . $i];
$descrip = $_POST['descrip_' . $i];
$unit = $_POST['unit_' . $i];
$rate = $_POST['rate_' . $i];
mysql_query("INSERT INTO `quotdtl`(vouchno, orderby, srno, `descrip`, unit, rate)
VALUES('$qvouch', '$ord', '$srno', '$descrip', '$unit', '$rate')") or die(mysql_error());
}
mysql_query("DELETE FROM quotnotes WHERE vouchno='$qvouch'") or die(mysql_error());
for ($i = 1; $i <= $h; $i++) {
$notes = $_POST['notes' . $i];
mysql_query("INSERT INTO `quotnotes`(vouchno, `notes`)
VALUES('$qvouch', '$notes')") or die(mysql_error());
}
if ($addflag == 1) {
mysql_query("INSERT INTO `quotmain`(vouchno, `vouchdt`, `name`, refno, `attn`, `subject`, `message`, `rem1`, `status`, `username`)
VALUES($qvouch, '$vouchdt', '$name', '$refno', '$attn', '$subj', '$msg', '$rem', '$status','$_SESSION[username]')") or die(mysql_error());
insmess();
header("refresh: 1; quotation.php?mode=true");
} else {
$mvouch = $_POST["vouch"];
mysql_query("UPDATE `quotmain` SET `vouchdt`='$vouchdt', `name`='$name', refno='$refno', `attn`='$attn', `subject`='$subj',
`message`='$msg', `rem1`='$rem', `username`='$_SESSION[username]' WHERE vouchno = '$mvouch' ") or die(mysql_error());
updmess();
header("refresh: 1; menu.php?action=quotation");
}
}