0

在我的表单上,我有 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 个工作,最后一次提交什么都不做(名称='submit')有什么建议吗?

4

1 回答 1

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");
 }
于 2013-04-09T23:43:55.533 回答