poleposters Posted November 20, 2009 Share Posted November 20, 2009 Hi all. I have simple search feature on my site that displays a series of listings to user profiles. The User profile has the URL www.domain.com/users.php?id=1 What I'd like to do is create a link that (once the viewer is done viewing the user profile) allows them to return to the search results page. Which looks like (depending on what search was performed) www.domain.com/search.php?gender=male&age=22&language=english Is there a way to do this? If I haven't been clear, please let me know. Its been a long day. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/182249-create-a-link-to-previous-page-without-using-back-button/ Share on other sites More sharing options...
Alex Posted November 20, 2009 Share Posted November 20, 2009 You could use JavaScript, example: <a href="#" onclick="history.go(-1);">Back</a> You should also make sure that they actually came from your search page though, and they didn't just click a link like www.domain.com/users.php?id=1 Quote Link to comment https://forums.phpfreaks.com/topic/182249-create-a-link-to-previous-page-without-using-back-button/#findComment-961684 Share on other sites More sharing options...
emopoops Posted November 20, 2009 Share Posted November 20, 2009 once your on the pfile. u need to know where u came from. theres a built in variable http referrer. you echo that little number in a link and there you go. thats right back where u came from folks! Quote Link to comment https://forums.phpfreaks.com/topic/182249-create-a-link-to-previous-page-without-using-back-button/#findComment-961712 Share on other sites More sharing options...
poleposters Posted November 23, 2009 Author Share Posted November 23, 2009 Thank you both. I've investigated both methods. Just have to choose the best one for my site. Great point on checking that they've actually come across the page from a search page. I wouldn't of thought of that. Is that also a javascript method? I'm not too good with javascript. Quote Link to comment https://forums.phpfreaks.com/topic/182249-create-a-link-to-previous-page-without-using-back-button/#findComment-963699 Share on other sites More sharing options...
emopoops Posted November 23, 2009 Share Posted November 23, 2009 yea i use both of them. but some poeple are dumb and disable javascript so u cant use that. and ive heard sometimes that the $_SERVER[HTTP_REFFERER} or what ever its called i cant remember... sometimes comes up empty even when the person has actually come from a page. Quote Link to comment https://forums.phpfreaks.com/topic/182249-create-a-link-to-previous-page-without-using-back-button/#findComment-964364 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.