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... Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/ Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Try using $_SERVER['HTTP_REFERER'] Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523387 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! Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523388 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? Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523390 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 Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523391 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 Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523393 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. Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523394 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. Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523404 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. Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523405 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. Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523409 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 Link to comment https://forums.phpfreaks.com/topic/102233-previous-page/#findComment-523412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.