表单php上的多个提交
在我的表单中,我有3个提交,我想知道处理这些按钮的最佳方式,因为默认操作与表单相同:表单php上的多个提交,php,forms,submit,Php,Forms,Submit,在我的表单中,我有3个提交,我想知道处理这些按钮的最佳方式,因为默认操作与表单相同: <form method="POST" action="file_where_form_is.php"> Name:<input type='text' name='name'> <input type='submit' name='add' value='Add Names' ONCLICK='window.location.href="file_wher
<form method="POST" action="file_where_form_is.php">
Name:<input type='text' name='name'>
<input type='submit' name='add' value='Add Names' ONCLICK='window.location.href="file_where_form_is.php">
<input type='submit'name='Preview'value='Preview'ONCLICK='window.location.href="file_where_form_is.php">
<input type='submit' name='submit'value='Submit' ONCLICK='window.location.href="send.php">
</form>
姓名:
我最终发现在标题部分添加了如下内容:
if(isset($_POST['submit'])){
header("location: somefile.php");
}
elseif(isset($_POST['Preview'])){
header("location: anotherfile.php");
}
elseif(isset($_POST['add'])){
header("location: anotheronefile.php");
}
您希望发生什么/尝试做什么?我在预览我添加的名称后,在表中添加一些名称,然后添加到数据库(send.php)