send two forms with one button to one php receiver with ajaxSubmit() function
I have two forms in html
<form id="form1" action="update.php" method="post">
<input
type="text" name="username1">
</form>
<form id="form2" action="update.php" method="post">
<input type="text" name="username2">
</form>
<button type="button" onclick="submitTwoForms();">Send</button>
Now I send these two forms to one php page named "update.php" by using jQuery Form Plugin:
function submitTwoForms() {
$('#form1, #form2').ajaxSubmit();
}
The Problem is, update.php can only get the data from the form1, namely the username1. How can update.php get the data from form1 AND form2 at the same time?
My update.php like this:
<?php
$user1
= $_POST['username1'];
$user2
= $_POST['username2'];
?>
And I want to keep these:
- I want use ajaxSubmit() function because it can handle file uploading.
- I want to keep two forms in html, not one.
Thanks for any help in advance!