knowing from what page I came from

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

knowing from what page I came from

Post by jasongr »

Hello people

I have 3 pages in the application
both page A.html and page B.html have a link to page C.php
When I get to page C.php I need to know from what page I came from.

I know that I can pass it as a parameter in the URL, but I was wondering if there is a more basic construct in PHP that will allow me to know this without having to perform an explicit action

regards
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

You could check the value of $_SERVER['HTTP_REFERER']. However, it isn't guaranteed to always be set.
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

Post by jasongr »

thanks, I will check it out
If it won't work, I will have to take care of it explicitly when I construct the URL to C.php
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

jasongr wrote:thanks, I will check it out
If it won't work, I will have to take care of it explicitly when I construct the URL to C.php

you may want do that anyway.

the referer header is optional, meaning browsers do not need to send it. many dont.
Post Reply