Is there PHP code to let the visitor return to the last page he came from (category)?

by nik0 Banned
1 replies
  • WEB DESIGN
  • |
I have this code:

Code:
<h6 class="prodboxbuy"><a class='ssesaddbutton' href='<?php if ( != ""){ echo ; } ?>'><?php echo ; ?></a></h6>
It's the code for a button, when the user clicks on it it takes him to the URL that I specified in an input box in my WP post editor. However I can only insert one URL and that will be used on the whole site while I only want to point visitors back to the category page when they are present on the product page.

While when they are on the category page I want to send them somehwere else. That category part is taken care of but sending them to a different url (back to the last category they came from) is my problem here.

The <?php if ($url != ""){echo $url; } ?> is the code that's responsible for sending them to the URL that I specified in that input box so that's the one I need to alter. Obvious I can replace that part with a hardcoded url but that would only work for one category then, right now I hardcoded my homepage in it but that's also not the solution.

As a last resort I can also remove the button from that product page but I rather drive them back somewhere from that spot.

Please help!
#category #code #page #php #return #visitor
  • Profile picture of the author nik0
    Banned
    EDIT: Solution found:

    <a href='javascript:history.go(-1)'></a>
    {{ DiscussionBoard.errors[8898564].message }}

Trending Topics