如何在没有表单的情况下将POST数据携带到PHP中的新页面? [英] How can I carry POST data to a new page in PHP without a form?

查看:224
本文介绍了如何在没有表单的情况下将POST数据携带到PHP中的新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:我可以通过询问是否有办法来简化这个问题 header('Location:/msg_form.php?error=3') except发送错误= 3和所有其他表单信息通过POST。我认为简短的答案是否定的,但有其他方法可以做事情。

I could simplify this question by asking is there a way to do something like header('Location: /msg_form.php?error=3') except sending error=3 and all the other form info via POST. I think the short answer is no, but there are alternative ways to do things.

网站,使用GET的一切,但我需要发送消息到大的人名单,所以我不得不切换到使用POST。但是,当您提交消息窗体并且有错误时,拧紧系统。表单提交到处理页面,如果有错误,它应该重定向回到表单页面,但现在转储所有的POST信息。 :(

I integrated a message system into my website which used GET for everything but I needed to send messages to large lists of people so I had to switch to using POST. However that screws up the system when you submit the message form and there are errors. The form submits to a processing page and if there are errors it is supposed to redirect back to a form page but now that dumps all the POST info. :(

我有没有什么方法来模拟来自PHP处理页面的表单提交?我认为curl可以为我做这个,但到目前为止似乎只是将POSTS发送到netherworld,但实际上没有重定向浏览器。

Isn't there some way for me to simulate a form submission from the php processing page? I would think that curl could do this for me but so far it seems to just send POSTS out to the netherworld but not actually redirect the browser.

我想我可以打印出一个带有一些隐藏变量的表单,然后重定向与html或者javascript,但这似乎很蠢,也可以将处理器集成到表单页面,我可以做,但我不想重新安排很多东西。

I guess I could have it print out a form with some hidden variables and then redirect with html or javascript but that seems dumb. Also I could integrate the processor right into the form page, which I might do, but I'd rather not re-arrange to much stuff.

推荐答案

通常,我将使用相同的页面进行表单处理和表单处理。在页面顶部,检查POST变量,并相应地处理。任何错误,然后在处理代码结束时,如果有错误,重新显示带有错误的输入页面,否则重定向或显示一个感谢页面等。

Often, I will use the same page for form entry and form processing. At the top of the page, you check for the POST variables, and process accordingly. I build a string with any errors. Then at the end of the processing code, if there are errors, re-display the entry page with the errors. Otherwise, redirect or display a thank you page, etc.

您还可以使用jQuery,在保持页面的同时提交表单,并处理响应(显示返回的错误或重定向)。有许多方法可以解决您的问题。

You could also use jQuery, to submit the form while staying on the page, and process the response (display the errors that come back, or redirect).. There are many ways to solve your issue.

这篇关于如何在没有表单的情况下将POST数据携带到PHP中的新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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