Ninjakreborn Posted January 22, 2007 Share Posted January 22, 2007 [code]<a href="/mainadmin/admin.php" title="Return">Home</a> | <a href="<?php $_SERVER['HTTP_REFERER']; ?>" title="Return">Return</a> | <a href="/mainadmin/logout.php" title="Logout">Logout</a>[/code]This is what I was attempting to use, to allow me to allow the person to go back to the previous page, to an extent. However when I use it as an inclusion, it makes it show the link as to that page. I need it to work, the other way around. Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/ Share on other sites More sharing options...
redbullmarky Posted January 22, 2007 Share Posted January 22, 2007 if, in the case of the page being called directly (ie, no HTTP_REFERER set) then you're gonna end up with <a href="" title="Return">Return</a>. Some browsers I believe can mask the REFERER anyway.which i do believe will cause a click of the link to actually load the current page. Right click/View Source and you'll see what I mean.To be honest, it's a pretty poor way of implementing this type of thing, so not exactly sure why you see fit to try it this way...? Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166461 Share on other sites More sharing options...
Ninjakreborn Posted January 22, 2007 Author Share Posted January 22, 2007 Ok, good point. I am doing the linking manually (breadcrumb) navigation instead. I am doing that now, it's just the admin panel on this site (program), I was building has always not been the best at userfriendliness, I was doing what I could to increase it, the breadcrumb navigation came to mind, and I have done it through 30%R of the admin panel, and it's already so much easier to get around. I might start doing that on all of the site's I build, or maybe only where it's needed. Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166463 Share on other sites More sharing options...
Jessica Posted January 22, 2007 Share Posted January 22, 2007 "This is what I was attempting to use, to allow me to allow the person to go back to the previous page"Most browsers have a BACK button. That's what it's for. No reason to add that stuff in your site when it already exists... Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166464 Share on other sites More sharing options...
obsidian Posted January 22, 2007 Share Posted January 22, 2007 Busi, there's a really good (easy) workaround... Keep a session variable with referrer information. How might you do that? Simply at the [b]end[/b] of your page, after all your PHP processing has occurred and all your links are set, set a session variable to the current script ($_SERVER['PHP_SELF'] or such). Then, when you want to reference the referrer, just use that session variable you have manually set. By setting it at the [b]end[/b] of every page, you can be assured that you will be ready for the next page. Also, you can test against that variable, and if it's empty, you know that this is the first page they've hid directly, and you could just opt to not show the "back" link.[b]**EDIT**[/b]jesirose has a very good point ;) LOL Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166466 Share on other sites More sharing options...
cmgmyr Posted January 22, 2007 Share Posted January 22, 2007 you can also use some JS if you want...[code=php:0]echo "[ <a href=\"#\" title=\"Back\" onclick=\"javascript:history.back()\">Back</a> ]<br /><br />";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166468 Share on other sites More sharing options...
aztec Posted January 22, 2007 Share Posted January 22, 2007 I use a little bit of Javascript on one of my sites as follows:<p><center><a href="#" onClick="history.go(-1)"></a> <input type=button value="Return" onClick="history.go(-1)"></center><p>While you can use the back arrow as jesiroe says on occasions this little script tidies things up and places a button on the page named Return. Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166479 Share on other sites More sharing options...
Ninjakreborn Posted January 22, 2007 Author Share Posted January 22, 2007 Yes, a lot of time's there is a reason to put a back button functionality on a site. Depending. I have had a lot of clients come to me, and say have a button there that returns to the previous page, or goes back to "this page", or "this page", the javascript won't serve this purpose. So I did the breadcrumb, and thanks obsidian for that advice, I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166481 Share on other sites More sharing options...
boo_lolly Posted January 22, 2007 Share Posted January 22, 2007 [quote author=cmgmyr link=topic=123522.msg510642#msg510642 date=1169484949]you can also use some JS if you want...[code=php:0]echo "[ <a href=\"#\" title=\"Back\" onclick=\"javascript:history.back()\">Back</a> ]<br /><br />";[/code][/quote]that's what i was going to suggest. however, if the user is directed to the page from a search engine, this 'return' button will direct them back to the search results page. i assume business wants the 'return' button to go back to a page within the website. to do this, i think the $_SESSION['previous_page'] idea is best. Quote Link to comment https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/#findComment-166494 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.