PHP:在页面之间传递非形式变量? [英] PHP: Pass non-form variables between pages?

查看:45
本文介绍了PHP:在页面之间传递非形式变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面.用户提交页面并将其发送到PHP结果页面.它工作正常.现在,我希望结果页面链接到另一个页面,并且该页面上的元素取决于结果页面上的内容.我知道如何将表单变量传递到另一个页面,但是我对传递非表单变量一无所知.

I have a page. The user submits the page and sends it to a PHP results page. It works fine. Now, I want the results page to link to another page, and for the elements on that page to depend on what was on the results page. I know how to pass form variables to another page, but I don't know anything about passing non-form variables.

根据我在网络上的搜索,我最好的猜测是我应该通过URL进行传递.这样对吗?如果是这样,则可能是一个问题:我希望结果页面传递到的页面将具有一个表单,并且用户将通过单击提交转到另一个结果页面(表单数据将通过POST发送).如果用户要使用POST转到其他页面,我可以将非表单数据(旧的结果页面变量)与表单数据一起发送吗?

From my searching on the web, my best guess is that I should be passing by URL. Is this correct? If so, a possible problem: the page I want the results page to pass to will have a form, and the user will go to yet another results page by clicking submit (the form data will be sent by POST). Can I send the non-form data (the old results page variable) along with the form data, if the user is going to the other page using POST?

推荐答案

有几个选项.但是,最简单的方法可能是使用隐藏的输入字段简单地传递数据.

There are several options. However, the easiest may be to simply pass the data on using hidden input fields.

其他选项可能是使用会话,将表单之间的存储在数据库中或其中的某种组合.

Other options would be using the session, storing to a database between forms, or some combination therein.

这篇关于PHP:在页面之间传递非形式变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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