PHP - how to create back/next link - Asked By Olusegun A. on 12-Jul-10 11:44 AM

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
Christiano Coutinho replied to Olusegun A. on 12-Jul-10 12:00 PM
Hi!

You can use a single "back" link using javascript:
<a href="javascript: history.go(-1)">Back to Previous Page</a>

You can also use a session var ($_[SESSION]) to store an array containing all the pages the user already visited. Using this, you will be able to create the logic to the "Next" button. You can also use the same logic above using diferent values in history.go funciton.

Anyway, I think you should implement the "Next" button explicitly, like in a wizard. Ohterwise, I cant realize how you would perform such task.

Good luck.
Gayathri S replied to Olusegun A. on 15-Jul-10 06:20 AM
You can do this using simple javascript links. But this makes use of the browser's history.

Example code:
<a href="javascript:void(0);" onClick="javascript: history.back()" />Back</a>
<a href="javascript:void(0);" onClick="javascript: history.forward()" />Forward</a>