|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello; I just wrote a script that needs to know what the referring page is but "$_SERVER['HTTP_REFERER']" does not seem to be working. Is there a way around this?
Many thanks in advance for your help and code! Best Regards, Joe of Christ For Life Ministries http://www.jc4life.org/
__________________
Check out 4Life today! |
|
#2
|
|||
|
|||
|
One Idea
You could try adding a get var and passing the name of the page along to the next page. This would work if page names were coming out of a database. $_SERVER var should work though. There might be a prob in the php.ini file. I am not sure why your page would need to know the refering page. Could you explain a bit more of what you are trying to do?
|
|
#3
|
|||
|
|||
|
From what I have read, $_SERVER['HTTP_REFERER'] is extremely unreliable and basically useless.... however there may be work-arounds depending on your specific needs and purposes. Care to elaborate?
|
|
#4
|
|||
|
|||
|
Well, my project is rather hard to explain. The reason that I can not just use a variable is because of the way my site is set up. I use Apache's Mod-Rewrite module to make the pages look like a directory structure - this is to be more search engine friendly. For example, "main.php" would be accessed as "/main/". To add a whole nother url to that would not only cause potential problems but ruin the simplicity and beauty of the directory-like structure previously mentioned.
An instance where I would need to know what the previous page was appears in my Customization page. This page allows visitors to change various things on the page and allow them to apply those settings to either the referring page or the entire site. While writing this post, I did come up with an idea of how to do this in JavaScript but that would leave my non-JS users out in the cold. In comforming both with accessibility standards and other web standards, I need to support those people too. A big example of this once again comes from the Customization page. In JS-enabled browsers this page will be opened in a new window but instead of using the window command in the HREF I use it in the onClick attribute and the provide the actual link in the HREF. Well, I apologize for the length of this post, but I hope that now understand my dilema! Many thanks for your help in advance! Joe Last edited by Joe4JC : October 10th, 2003 at 06:15 AM. |
|
#5
|
|||
|
|||
|
Sounds like you are running PHP in cgi mode... If you want a quick fix, avoid using the CGI version. If this is not an option with your current host, change your host.
On another note, you could just use sessions and record the current location which would be useable on each page view.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#6
|
|||
|
|||
|
Nope, I am using PHP in module mode (the correct term?). I do not have the option of switching hosts since I just signed up with them. The thing with sessions, though, is, because of their setup or something, the "PHPSESSID=" gets apended to the URL. Thanks, anyhow!
Joe |
|
#7
|
||||
|
||||
|
Have you tried getenv("HTTP_REFERER")? I'm not sure that's any more reliable than using the $_SERVER variable, but I've never had problems with it.
|
|
#8
|
|||
|
|||
|
PHP Code:
|
|
#9
|
|||
|
|||
|
Thank you guys for your suggestions but I still have found no solution. Dhouston, here is a quote from PHP.net in reference to "getenv":
Quote:
Joe |
|
#10
|
||||
|
||||
|
If you wanted to get really bizarre-fancy, you could store the last page visited in session variable or a cookie and redirect to that. For every page but the page that has to do the processing, you'd write the session variable, and then when you ran the script in question, you'd test for that variable. Since you're not overwriting the session variable with the URL of the script in question, it won't overwrite what was last set, so you'll effectively have the referer. This assumes you're wanting to ensure that somebody's coming from a page on your site, though, which may not be what you want to do at all.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > alternative to HTTP_REFERER? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|