PHP open another webpage with POST data(PHP用POST数据打开另一个网页)
问题描述
我是 PHP 新手,我正在尝试做一些可能是不好的做法并且很可能是不可能的事情.我基本上只是在拼凑一些东西来测试我的知识,看看 PHP 能做什么.
I'm new to PHP and I'm trying to do something that may be bad practise and may well be impossible. I'm basically just hacking something together to test my knowledge and see what PHP can do.
我有一个网页,其中包含收集数据的表单.这被提交给一个 PHP 脚本,该脚本执行一堆处理 - 但实际上并不显示任何重要的东西.我想要的是,一旦处理完成,脚本就会告诉浏览器打开另一个页面,显示结果.
I have one webpage with a form that collects data. That is submited to a PHP script that does a bunch of processing - but doesn't actually display anything important. What I want is that once the processing is done, the script then tells the browser to open another page, where the results are displayed.
我知道我可以使用 header('Location: page.php'); 但我不知道如何提供 POST 数据.我怎样才能做到这一点?或者,还有其他方法可以告诉浏览器打开另一个页面吗?
I know I can use header('Location: page.php'); but I can't work out how to provide POST data with this. How can I do that? Alternatively, is there another way to tell the browser to open another page?
我从回复中得到的是,可能使用各种黑客来做到这一点,但我最好将处理和显示代码放在一个文件中.我对此很满意;这比什么都重要.
What I'm taking from the responses is that it's possible to do this using various hacks but I'd be better off to just have the processing and the display code in one file. I'm happy with that; this was an experiment more than anything.
推荐答案
真的需要处理完再调用另一个页面吗?我可能会做以下事情:
Is it really necessary to call another page after the processing is done? I'd probably do the following:
<form method="post" action="display.php">
...
</form>
display.php:
display.php:
if ($_POST) {
require_once(process.php);
process($_POST);
display_results;
}
包含处理 post 请求所需的代码的 process.php.
with process.php containing the code necessary for processing the post request.
或者,您可以使用 cURL 库之类的东西将处理结果传递给您自己指定的页面.不知道这是否真的是你所追求的.
Alternatively, you could use something like the cURL library to pass the results of the processing to a page specified by yourself. Don't know if that's really what you're after though.
这篇关于PHP用POST数据打开另一个网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP用POST数据打开另一个网页
基础教程推荐
- PHP 类:全局变量作为类中的属性 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
