【发布时间】:2013-02-11 18:25:59
【问题描述】:
我在 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>
现在我使用 jQuery 表单插件将这两个表单发送到一个名为“update.php”的 php 页面。 像这样的Javascript:
function submitTwoForms() {
$('#form1, #form2').ajaxSubmit();
}
问题是,update.php只能从form1获取数据,即username1。 update.php如何同时从form1和form2获取数据?
我的 update.php 是这样的:
<?php
$user1 = $_POST['username1'];
$user2 = $_POST['username2'];
?>
我想保留这些:
- 我想使用 ajaxSubmit() 函数,因为它可以处理文件上传。
- 我想在 html 中保留两个表单,而不是一个。
提前感谢您的帮助!
【问题讨论】: