繁体   English   中英

在表单php上多次提交

[英]Multiple submit on form php

在我的表单上,我有3个Submit,我想知道处理这些按钮的最佳方法,因为默认操作是相同的表单:

<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> 

这似乎不能完全正常工作,只是前两次工作,最后一次提交什么都不做(名称为“ submit”),有什么建议吗?

我终于在标题部分发现添加如下内容:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM