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?
views:
77answers:
3
+3
A:
<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>
Kugel
2009-11-06 01:31:26
not following standards.
thephpdeveloper
2009-11-06 01:33:23
+2
A:
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>
agentile
2009-11-06 02:38:32