简体   繁体   中英

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.

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

 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

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

how can i redirect this page to 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..

how can I do it?

Why dont you use a session variable instead of using GET on the register.php page?

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

You have several options, using header() with Location: (one of examples in manual):

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

Or meta redirect :

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

Or javascript redirect :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM