Jump to content

Recommended Posts

[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.
Link to comment
https://forums.phpfreaks.com/topic/35239-going-back-to-previous-page/
Share on other sites

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...?
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.
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
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.
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 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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.