Home  >  Article  >  php教程  >  php实现表单多按钮提交action的处理方法,action处理方法

php实现表单多按钮提交action的处理方法,action处理方法

WBOY
WBOYOriginal
2016-06-13 08:52:44999browse

php实现表单多按钮提交action的处理方法,action处理方法

表单内有两个提交按钮,要实现当点击不同的提交按钮时,分别进行两个不同的处理过程,在这里有实现表单多按钮提交action的处理方法分享给大家。

用PHP判断,一个表单两个按钮,按钮的name属性设为相同,但值设为不同,表单提交后,只需要判断提交上来的值就可以转到不同的处理过程去,这个方法比较合理,适合多个按钮在一个表单里。

PHP方法,代码如下:

<&#63;php  
 echo "$sub<br>\n";  
 if ("s1"==$sub)  
 {  
  ...  
 }  
 else if ("s2"==$sub)  
 {  
  ...  
 }  
 &#63;>  
 <html>  
 <head><title></title></head>  
 <body>  
 <form action="<&#63;php print("$PHP_SELF"); &#63;>" method="get">  
 <input type="submit" name="sub" value="s1">  
 <input type="submit" name="sub" value="s2">  
 </form>  
 </body>  
 </html>  
 &#63;> 

 以上就是php实现表单多按钮提交action的方法,希望对大家的学习有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn