html php 标识表单发布数据 [英] html php identifying the form posting data

查看:41
本文介绍了html php 标识表单发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个表单标签的 php 页面.每个表单都处理一个特定的选项卡.这只是一个搜索,但每个选项卡都提供日期、数字或名称的搜索.

I have a php page which has multiple form tags. each form is dealing with a specific tab. It is simply a search but each tab provides a search of either date, number, or name.

每个表单标签都有不同的名称....我如何知道结果页面中提交了哪个表单以相应地自定义数据库搜索?

each form tag has a different name....how can I know which form was submitted in the result page to customize the database search accordingly?

是 $_POST 还是 $_REQUEST 的东西?

is it something with $_POST or $_REQUEST ?

    <form name="invoice" action="result.php" method="POST"><br><br>
    <form name="customer" action="result.php" method="POST"><br><br>
    <form name="customer" action="result.php" method="POST"><br><br>

以上每个都包含一个带有输入框和提交按钮的表格.

each of the above contains a table with input box and submit button.

谢谢,

推荐答案

例如,您可以在每个提交按钮中添加名称和值,如下所示:

You could, for one, in each submit button add a name and value, like so:

<form>
   <input type="submit" name="action" value="search_invoice" />
   ... 
</form>

<form>
   <input type="submit" name="action" value="search_customer" />
   ...
</form>

然后在你的 php

switch($_POST['action']) {
   case 'search_invoice':
      // ur code
      break;

   case 'search_customer': default:
      // ur code
      break;
}

但请注意,旧版本的 Firefox 无法正确提交输入类型提交的键 => 值对.

Be aware though, older versions of firefox doesn't properly submits the key => value pair of input type submit.

我通常使用的另一个解决方案是放置一个 <input type="hidden" name="action" value="your_customAction"/>

Another solution I usually use is to put an <input type="hidden" name="action" value="your_customAction" />

这篇关于html php 标识表单发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆