再次重定向同一页面

时间:2012-02-19 21:31:40

标签: php redirect http-headers

我有页面register.php,用于获取用户信息,在完成表单后,它会提交到另一个页面post.php。

post.php执行两个操作,它按顺序将输入数据添加到2个位置,1.php和2.php,因此数据流是

 register.php -->post.php --> 1.php -->2.php -->register.php?value='abc'

一旦将数据发送到这两个位置,再次加载register.php,但此时间页面在浏览器中显示

http://www.example.com/register.php?value='abc'

如何将此页面重定向到welcome.php?新的流程将是

register.php -->post.php --> 1.php -->2.php -->register.php?value='abc' -->welcome.php
至于这样一个奇怪的流程,那个相当学习的东西,并没有问题,我抓到了最后一步,当我必须将页面重定向到welcome.php ..

我该怎么办?

3 个答案:

答案 0 :(得分:2)

为什么不使用会话变量而不是在register.php页面上使用GET?

if(isset($_SESSION['value']){
    header('Location:');
}

答案 1 :(得分:1)

您可以使用header()Location:(手册中的示例之一)使用多个选项:

header( 'Location: welcome.php');
// Or with all parameters:
header( 'Location: welcome.php', true, 301);

meta redirect

<meta http-equiv="refresh" content="0; url=http://example.com/">

javascript redirect

window.location.href = 'welcome.php'

答案 2 :(得分:1)

这可能就是你想要的

if(str_pos($_SERVER['HTTP_REFERER'],"2.php") > 0){
   header( 'Location: welcome.php', true,301);
}

希望有所帮助