在表格php上多次提交

时间:2013-04-09 22:38:02

标签: 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_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> 

这似乎没有完全奏效,只有2个第一个作品和最后一个提交什么都不做(名字='提交') 有什么建议吗?

1 个答案:

答案 0 :(得分:1)

我终于在标题部分找到了这样的内容:

 if(isset($_POST['submit'])){
      header("location: somefile.php");
 }
 elseif(isset($_POST['Preview'])){
       header("location: anotherfile.php");
 }
 elseif(isset($_POST['add'])){
       header("location: anotheronefile.php");
 }