Here is my problem. I implemented a back button using:

echo '<a href="' . $_SERVER  'HTTP_REFERER'] . '">Previous</a>';

This gets stuck in a loop when I try to go back more than one level.

Can anyone help?

Member Avatar for Dukane

You might want to try using JavaScript to do this. What's happening in your code is that you use the referrer (the last page you visited to go back). so for example, you click a link on page A to go to page B. the referrer to page B is page A. when you click on your "Previous" link, it will take you to the referrer of page B, which is page A. So now you are on page A, but the referrer to this page A is page B, the page you last came from...back and forth, back and forth.

Take a look at this http://www.devguru.com/Technologies/Ecmascript/Quickref/history_go.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.