Jump to content


http_referer problem

  • Please log in to reply
2 replies to this topic

#1 jimmckerchar

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 March 2006 - 11:01 AM

Hi all.

Just a quick question which i hope someone will be able to answer.

A university project involves creatng a basic php/mysql bookstore. There are several situations where, if they are not logged in, they are sent to a login page. Once they have logged in succesfully, i would like them to be re-directed back to the page that they came from.

The problem is that the login page submits to itself using $_SERVER['PHP_SELF'] so the url passed into http_referer is always the login page.... and not the page the user came from before logging in.

i have tried to store the http_referer url in a session when the login page is loaded. By echoing it when th page loads i can see it is correct, but when i submit the form it then becomes login.php.

This is one of the last things i need to do before handing in so if anyone can help i would REALLY appreciate it. i was up till 3:30am last night trying to figure it out and i've been looking at it so long i just can't see what the problem is.

Many thanks in advance.


#2 redbullmarky

  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 24 March 2006 - 11:22 AM


if (!stristr($_SERVER['HTTP_REFERER'], 'login.php'))
   $_SESSION['referer'] = $_SERVER['HTTP_REFERER'];

that should start you off.

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 jimmckerchar

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 27 March 2006 - 12:19 AM


it seems so obvious looking at it.

will try it as soon as i finish this damn design work

cheers mate.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users