Hello there,
I want to create back link and next link on my pages so that visitors can go back to the previously visited pages, how do i get the URL of these previous pages, or how do i go about it.
regards
how to create back/next link
Moderator: General Moderators
-
websitesca
- Forum Newbie
- Posts: 16
- Joined: Fri Jul 09, 2010 2:47 pm
Re: how to create back/next link
There are a number of ways to go about this. It really depends on your website design of course.
URL PASSING METHOD:
This is probably the best method. When a user clicks a link to go FORWARD, you could pass some info about where they are coming from in the url. So you would make a link like:
COOKIES/SESSION METHOD:
This requires use of the $_SESSION variable. When on any particular page, simply do this:
Now you can use that session variable anywhere.
JAVASCRIPT METHOD:
This doesn't really involve PHP, but it still can work. This works on the client side, so the BROWSER knows where you've been last:
You can put this in a link, or in a form, but basically the code is history.back();
I hope that helps you with your website!
Georges,
http://www.websites.ca
URL PASSING METHOD:
This is probably the best method. When a user clicks a link to go FORWARD, you could pass some info about where they are coming from in the url. So you would make a link like:
Code: Select all
$link = "<a href='page.php?previous=page57'>Next Page</a>";This requires use of the $_SESSION variable. When on any particular page, simply do this:
Code: Select all
$_SESSION["previous_page"] = $_SERVER["REQUEST_URI"];JAVASCRIPT METHOD:
This doesn't really involve PHP, but it still can work. This works on the client side, so the BROWSER knows where you've been last:
You can put this in a link, or in a form, but basically the code is history.back();
Code: Select all
<FORM>
<INPUT type="button" value="Click here to go back" onClick="history.back()">
</FORM>Georges,
http://www.websites.ca