Getting previous page url

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
hvolvo
Forum Newbie
Posts: 6
Joined: Thu Mar 27, 2008 2:01 am

Getting previous page url

Post by hvolvo »

hi,
i am having a page on which i check if the user is logged in. if the user is logged in i save some details in the db and display a link for the user. on clicking this link a pdf/html page is opened.
Now when the user preses the back button of the browser, he is taken back to the same page, where it checks that the user is logged in and again saves details to the db.
I tried using HTTP_REFERER to check if the url of the link and that of the previous page is same, but HTTP_REFERER does not give me the link of the pdf since the user is using back button.
Is there a way to get the url of the previous page in this case :?:
i dont want to disable the browser button or anything

Thanking in advance.
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: Getting previous page url

Post by Reviresco »

If I understand the question correctly, you just want to check to see if the user's logged in? Then setting a cookie or a $_SESSION variable would be the easiest way.
hvolvo
Forum Newbie
Posts: 6
Joined: Thu Mar 27, 2008 2:01 am

Re: Getting previous page url

Post by hvolvo »

The saving part works fine.. my problem is that the saving details in database is happening twice.
once if the user is already logged in and the second time, when he goes to the next page by clicking the link and tries to return back using the browser back button.
i don't want the saving of details happening the second time.
i ope i have made my self clear.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Getting previous page url

Post by Chris Corbyn »

Can't you just check if these "details" you save to the DB have already been saved? That seems like the most bulletproof fix.
Post Reply