How do I make a link that takes me to the previous page?

I have a list of thumbnails, when I click on one of these a big picture shows. When I click on the big picture I want to go back to the previous page, just like pressing the back button in explorer.

    Probably easier to do with JavaScript:

    <img src='img.gif' alt='' title='click photo to return' onClick='history.go(-1)'>
    

      The php way:

      <a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Go Back</a>

        Note that most of the time using HTTP_REFERER will probably work, but some browsers and proxies remove this header.

          rikmoncur wrote:

          The php way:

          <a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Go Back</a>

          This code gives me:

          Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

            Worked fine for me... must have been a typo when you implemented it.

            Paste the code that you used to implement rikmoncur's suggestion.

              Yes it works now, a little typo from me. Is it possible to modify this link to have a image instead of the text Go Back?

              <a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Go Back</a>

                Of course! Just replace "Go Back" with the HTML <IMG> element.

                  Write a Reply...