PHP - 通过POST重定向并发送数据 [英] PHP - Redirect and send data via POST

查看:136
本文介绍了PHP - 通过POST重定向并发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在线网关,需要使用隐藏字段提交HTML表单。我需要通过没有任何HTML表单的PHP脚本来完成此操作(我拥有DB中隐藏字段的数据)

通过GET发送数据:

  header('Location:http://www.provider.com/process.jsp?id=12345&name=John' ); 

并通过POST发送数据吗?

解决方案

你不能使用PHP来完成这项工作。

正如其他人所说,你可以使用cURL - 但是PHP代码成为客户端而不是浏览器。



如果您必须使用POST,那么唯一的方法就是使用PHP生成填充表单并使用window.onload hook来调用javascript来提交表单。



C。


I have an online gateway which requires an HTML form to be submitted with hidden fields. I need to do this via a PHP script without any HTML forms (I have the data for the hidden fields in a DB)

To do this sending data via GET:

header('Location: http://www.provider.com/process.jsp?id=12345&name=John');

And to do this sending data via POST?

解决方案

You can't do this using PHP.

As others have said, you could use cURL - but then the PHP code becomes the client rather than the browser.

If you must use POST, then the only way to do it would be to generate the populated form using PHP and use the window.onload hook to call javascript to submit the form.

C.

这篇关于PHP - 通过POST重定向并发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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