[英]Redirecting same page again
I have page register.php, which is used to get user informations, after completion of form, it submits to an-other page, post.php. 我有页面register.php,用于获取用户信息,完成表单后,它会提交到另一个页面post.php。
post.php performs two actions, it adds incoming data to 2 locations in order, 1.php and 2.php, so the flow of data is post.php执行两个操作,它将传入的数据按顺序添加到1.php和2.php的两个位置,因此数据流为
register.php -->post.php --> 1.php -->2.php -->register.php?value='abc'
once data is sent to both the locations, again register.php is loaded but this time page apears in browser like 一旦将数据发送到两个位置,将再次加载register.php,但这一次页面在浏览器中如
http://www.example.com/register.php?value='abc'
how can i redirect this page to welcome.php? 我如何将该页面重定向到welcome.php? the new flow will be
新的流程将是
register.php -->post.php --> 1.php -->2.php -->register.php?value='abc' -->welcome.php
as for as such a strange flow is concerned, that quite learning things, and there is no problem with it, i am caught at the last step, when i have to redirect the page to welcome.php.. 至于这样一个奇怪的流程,那是相当学习的东西,并且没有问题,当我不得不将页面重定向到welcome.php时,我陷入了最后一步。
how can I do it? 我该怎么做?
Why dont you use a session variable instead of using GET on the register.php page? 为什么不使用会话变量而不是在register.php页面上使用GET?
if(isset($_SESSION['value']){
header('Location:');
}
You have several options, using header()
with Location:
(one of examples in manual): 您有几种选择,可以将
header()
与Location:
一起使用header()
手册中的示例之一):
header( 'Location: welcome.php');
// Or with all parameters:
header( 'Location: welcome.php', true, 301);
Or meta redirect : 或meta重定向 :
<meta http-equiv="refresh" content="0; url=http://example.com/">
Or javascript redirect : 或javascript重定向 :
window.location.href = 'welcome.php'
This might be what you want 这可能就是您想要的
if(str_pos($_SERVER['HTTP_REFERER'],"2.php") > 0){
header( 'Location: welcome.php', true,301);
}
Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.