Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to save the values of two forms with one submit button in php
    primarykey
    data
    text
    <p>hi i have a three forms and one submit button which is located outside of all three forms and i want to save the values of all the three forms using php into mysql database can anyone help me in showing that how can it be done i am using jquery to submit the form values here is my jquery</p> <pre><code> &lt;script&gt; $(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(); }); }); &lt;/script&gt; </code></pre> <p>as i posted a query before this helped me in submitting the forms and now i want to save the values into my database</p> <p>her is my php code</p> <pre><code>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) &gt; 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 &lt;= $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 &lt;= $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"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload