以一种形式提交POST和GET变量 [英] Submit POST and GET variables in one form

查看:94
本文介绍了以一种形式提交POST和GET变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个显示来自MySQL数据库的数据的查询工具。用户将看到一个包含几十个动态生成复选框的表单,以便他们可以选择如何查看数据。这个数据是作为一个GET请求提交的,当请求的页面加载时显然显示在url中。



在输入表单的同一页面上,我有一个PHP数组,我动态生成,并需要发送到GET请求相同的地方。但是,我不希望这个数组中的值显示在URL中(我在内部使用它们),所以我想将它们作为POST请求提交。



显然,我不能同时执行G​​ET和POST请求。我是网络开发新手(计算机科学家,否则),并一直在挠头如何解决这个问题。



让我知道如果问题不是清除。



编辑:许多人建议我将它们添加到操作变量a中:



form action =process.php?get1 = value ...

所有这些输入都是动态生成的所以把它们放在action变量中是不可行的。

解决方案

Endophage:


如果它是一个PHP数组,只需将其存储在一个会话中即可。


这很好,显然,我在这里展示了我的网站开发绿色,因为我没有真正考虑过使用会话。


I'm working on a query tool that displays data from a MySQL database. The user is presented with a form containing a few dozen dynamically-generated checkboxes so that they can select how to view the data. This data is submitted as a GET request and is (obviously) displayed in the url when the requested page loads.

On the same page as the input form, I have a php array that I am generating dynamically and that needs to be sent to the same place as the GET request. However, I do not want the values in this array to be displayed in the URL (i'm using them internally) so I'd like to submit them as a POST request instead.

Obviously, I can't do both a GET and POST request at the same time. I'm new to web development (computer science guy, otherwise) and have been scratching my head on how to approach this.

Let me know if the problem isn't clear.

EDIT: Many have suggested I add them to the action variable a la:

form action="process.php?get1=value...

All of these inputs are generated dynamically so to put them in the action variable is not feasible.

解决方案

Endophage:

If it's a PHP array, just store it in a session.

This worked great. Obviously, I'm showing my web development greenness here as I didn't really consider using a session.

这篇关于以一种形式提交POST和GET变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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