Reputation: 16163
I am trying to create a button that knows what page you came from and enters that value into the anchor tag. Does anyone know a solution using either jQuery or PHP or both?
Upvotes: 1
Views: 331
Reputation: 1521
Also - if u just want an
<a href="javascript:go(-1)" class="dbutton" onClick="history.back()">Back</a>
Upvotes: 0
Reputation: 252
In PHP, you could keep track of the last page the user was on by using
$_SERVER['REQUEST_URI'];
and storing it in the session.
$_SESSION['last_page'] = $_SERVER['REQUEST_URI'];
and run it after your html for the current page is rendered, then in a link you could have something like this
<a href="<?php echo $_SESSION['last_page']; ?>">Back</a>
Upvotes: 2
Reputation: 19824
<FORM>
<INPUT TYPE="button" VALUE="Go Back" onClick="history.back()">
</FORM>
Also you can go back more pages, like this:
<FORM> <INPUT TYPE="button" VALUE="Go Back" onClick="history.go(-1)"> </FORM>
Upvotes: 3