Connecting Tech Pros Worldwide Forums | Help | Site Map

How to redirect to parent page in php?

dheerajjoshim's Avatar
Needs Regular Fix
 
Join Date: Jul 2009
Location: Bangalore, INDIA
Posts: 280
#1: Oct 14 '09
If I am redirecting many php pages to a single php page then how to redirect to
same page.
Ex.Suppose there are three pages One.php ,two.php,and three.php and from
these three pages I am redirecting to same page "Process.php" then

how to redirect to One.php if request comes from One.php?
how to redirect to two.php if request comes from two.php?
how to redirect to three.php if request comes from three.php?
best answer - posted by Markus
Pass an identifier along in the URL that specifies which page the request came from.

One.php:
Expand|Select|Wrap|Line Numbers
  1. header("Location: Process.php?ref=One.php");
  2.  
Process.php:
Expand|Select|Wrap|Line Numbers
  1. $referrer = $_GET['ref'];
  2.  
  3. // do something
  4.  
  5. header("Location: $referrer");
  6.  

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,953
#2: Oct 14 '09

re: How to redirect to parent page in php?


Pass an identifier along in the URL that specifies which page the request came from.

One.php:
Expand|Select|Wrap|Line Numbers
  1. header("Location: Process.php?ref=One.php");
  2.  
Process.php:
Expand|Select|Wrap|Line Numbers
  1. $referrer = $_GET['ref'];
  2.  
  3. // do something
  4.  
  5. header("Location: $referrer");
  6.  
dheerajjoshim's Avatar
Needs Regular Fix
 
Join Date: Jul 2009
Location: Bangalore, INDIA
Posts: 280
#3: Oct 21 '09

re: How to redirect to parent page in php?


Hey Mark, I tried the same solution as you gave as soon as i posted query.

I was looking for some built in functions if available for this purpose.

:(

Regards
Dheeraj Joshi
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,953
#4: Oct 21 '09

re: How to redirect to parent page in php?


Quote:

Originally Posted by dheerajjoshim View Post

Hey Mark, I tried the same solution as you gave as soon as i posted query.

I was looking for some built in functions if available for this purpose.

:(

Regards
Dheeraj Joshi

Nope - this is something you will have to do. PHP doesn't provide tools for absolutely everything - only the tools you need.

Mark.
Reply