PHP POST值到另一个页面 [英] PHP POST values to another page

查看:333
本文介绍了PHP POST值到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个比较大的表单,并且当它将表单提交到与表单相同的页面并运行PHP验证。

基本上,如果所有的验证都正确,我想显示一个不同的页面,其中包含所有已发布的信息,并提供一种允许用户打印的报告或确认那个报告。表单中的数据并不存储在任何仅通过电子邮件发送的数据库中。



我遇到的问题是检索值,因为表单操作不会去报告页面本身。我需要一些建议。



我应该寻找一种改变表单动作位置的方法,即if全部有效的echo report.php,但这需要用户重新提交表单,还是有更好的方法?

您的建议将受到极大的欢迎。

解决方案

您应该在重定向之前将值存储在Session中。
然后在您的其他页面中将它们读出来并清除它们。

另请参阅:带重定向的PHP Pass数据



编辑:您也许还想看看帖子-Redirect-Get(PRG)模式。谷歌搜索它应该提出一些有用的例子


I have a rather larger form and when it submits it posts to the same page as the form and runs the PHP validation.

Basically if all is validated correctly I want to then show a different page with all the information that has been posted on it a sort of report or confirmation allowing the user to print the report. The data in the form is not stored in any database its just emailed off.

What I am having trouble with is retrieving the values as the form action is not going to the report page just itself. I therefore need some advice.

Should I look for a way of changing the form action location with an if i.e. if all valid echo report.php but this would require the user to resubmit the form, or is there a better way?

Your advice would be greatly received.

解决方案

You should probably store your values in Session before redirecting. Then in your other page read them out, and clear them.

See also: PHP Pass Data with Redirect

edit: You may also want to take a look at the Post-Redirect-Get (PRG) pattern. Googling it should bring up some usable examples

这篇关于PHP POST值到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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