[英]Distinguishing submit buttons in separate forms with PHP
If one has multiple input forms, is there a way for one to distinguish one submit button from the other? 如果一个人有多种输入形式,是否有一种方法可以区分一个提交按钮与另一个? The reason is I have two forms and each form performs a different task.
原因是我有两种形式,每种形式执行不同的任务。
Both forms do a submit and each submit will perform an SQL query. 两种形式都进行提交,并且每种提交都将执行SQL查询。 The first one is a SELECT FROM query to do a search for data and the second will do UPDATE or DELETE (using this code on two different pages) query.
第一个是SELECT FROM查询,用于搜索数据,第二个是UPDATE或DELETE (在两个不同页面上使用此代码)查询。
There might be many cases 可能有很多情况
First: if all the forms have the same action attribute then you will have to name the submit buttons differently. 首先:如果所有表单都具有相同的动作属性,那么您将不得不以不同的方式命名提交按钮。
second: If the forms have different actions then there is no need to name the buttons differently. 第二:如果表单具有不同的操作,则无需对按钮进行不同的命名。 You can achieve the task with the same name.
您可以使用相同的名称来完成任务。
Three: if you want some of the fileds to have a different form action in your form then you can try this 第三:如果您希望某些文件在表单中具有不同的表单操作,则可以尝试此操作
<form action="demo_form.asp">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit"><br>
<input type="submit" formaction="demo_admin.asp"
value="Submit as admin">
</form>
To learn about form action overriding click here 要了解表单操作覆盖,请点击此处
you specify the <input type="submit" name="form1" />
您指定
<input type="submit" name="form1" />
that name part is the way to specify seperately to php 该名称部分是单独指定php的方式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.