monkeypaw201 Posted April 21, 2008 Share Posted April 21, 2008 i need to take redirect via META Redirect to the previous page after running a script, but don't know how to get the previous page with PHP... i know how to take the current page... Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Try using $_SERVER['HTTP_REFERER'] Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 21, 2008 Share Posted April 21, 2008 $_SERVER['HTTP_REFERRER'] be aware not all clients send this info! Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted April 21, 2008 Author Share Posted April 21, 2008 Try using $_SERVER['HTTP_REFERER'] will that give me the full URL or just the page? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 or ,use some javascript ,type in on google javascript back button Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 That will give you the full url, but you can break it up and get the file, path and domain domain components out of it if you need them Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 I'd use javascript for that, because it's a tad more reliable. Or, I'd append the previous page "id" (I guess you could say) to the new page and have the new page interpret it and act on it. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Yes, having the previous page passing it's URL or "id" is the best way. That will gurantee that you get back to the page that 'called' the script and won't have to depend on the browser like the $_SERVER['HTTP_REFERER'] or JavaScript methods would. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 21, 2008 Share Posted April 21, 2008 NEVER RELY ON JAVASCRIPT html is your true friend javascript may not be around to help out! PS i concur with dptr - passing the previous url (or something that would allow you to get it like an id to a page in the database) is the best option. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 Yes, having the previous page passing it's URL or "id" is the best way. That will gurantee that you get back to the page that 'called' the script and won't have to depend on the browser like the $_SERVER['HTTP_REFERER'] or JavaScript methods would. Yeah, that's what I do in all of my scripts (when I need to), which is why I suggested it. I only suggested JS because he might get a bit confused with the PHP. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted April 21, 2008 Author Share Posted April 21, 2008 ok, thanks for all you guys' help, i decided to append a page_id variable to all pages and to pass it along, its working brilliantly now, thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.