The Praetorian Posted April 12, 2007 Share Posted April 12, 2007 Looked through the website but couldn't find this, even though I know it's there somewhere.What's the href for a link that sends you back one page? (The same as hitting back on the browser?) Link to comment Share on other sites More sharing options...
Skemcin Posted April 12, 2007 Share Posted April 12, 2007 Technically, you can do it two ways.a.) using a server side include language (asp, php, coldfusion) you could dynamically generate the link using the referral url (which is search engine friendly)b.) use javascript <a href="java script: void(0);" onclick="history.back();" title="[back]">back</a> Link to comment Share on other sites More sharing options...
The Praetorian Posted April 12, 2007 Author Share Posted April 12, 2007 Hm. How would I do the one with php?I tried the javascript one, and I got an "ACCESS FORBIDDEN: You don't have permission to access this object" error. Link to comment Share on other sites More sharing options...
Skemcin Posted April 12, 2007 Share Posted April 12, 2007 $ref=@$HTTP_REFERER;echo "<font face='Verdana' size='3'><b>Referrer of this page = $ref </b>"; Link to comment Share on other sites More sharing options...
The Praetorian Posted April 12, 2007 Author Share Posted April 12, 2007 Nothing shows up when I do that. Just to make sure I'm doing it right... $ref=@$HTTP_REFERER;if( !ereg("^.+@\.com$",$_REQUEST['Email'])){echo "<h1>Please Enter a Valid Email Address<br />$ref</h1>";} Link to comment Share on other sites More sharing options...
aspnetguy Posted April 12, 2007 Share Posted April 12, 2007 change this line echo "<h1>Please Enter a Valid Email Address<br />$ref</h1>"; to echo "<h1>Please Enter a Valid Email Address<br />{$ref}</h1>"; or echo "<h1>Please Enter a Valid Email Address<br />" . $ref . "</h1>"; Link to comment Share on other sites More sharing options...
The Praetorian Posted April 12, 2007 Author Share Posted April 12, 2007 Still nothing. Tried both lines and neither outputted anything.(Does it matter that I'm running this on a localhost? [i do have a server set up.]) Link to comment Share on other sites More sharing options...
aspnetguy Posted April 12, 2007 Share Posted April 12, 2007 try $ref = "Referrer: " . $_SERVER['HTTP_REFERER']; I'm not sure but @$HTTP_REFERER; may be for an older version of PHP. Also by writing an extra part of the string you'll see if it works. If all you get is "Referrer:" then you know it is a problem with the server variable or there is no referrer. Link to comment Share on other sites More sharing options...
Skemcin Posted April 12, 2007 Share Posted April 12, 2007 Thanks for stepping in aspnetguy - I'm no php guru, and I didn't want to convert him to ColdFusion until he is truly frustrated.:-D Link to comment Share on other sites More sharing options...
The Praetorian Posted April 12, 2007 Author Share Posted April 12, 2007 hm. Okay. It showed the url. Still not quite what I want it to do though. Can I use the variable in a link? (IE... <a href="$ref">Back</a> )? What I really want is just a link someone can click to send them back to the other page (so that all the info they entered into the form is still there.) But without having to press back on the browser.(On a side note, thanks for the help guys.) Link to comment Share on other sites More sharing options...
rswildy Posted April 12, 2007 Share Posted April 12, 2007 Try ("txt=Back;url=java script:history.back();"); Link to comment Share on other sites More sharing options...
The Praetorian Posted April 12, 2007 Author Share Posted April 12, 2007 Where do I put that? Do I turn it into a variable? Post it as is? Link to comment Share on other sites More sharing options...
rswildy Posted April 12, 2007 Share Posted April 12, 2007 Found a basic way should work :S <a href="java script: history.go(-1)">Back</a> Try that, If it doesn't work i don't know what to reccomend. Link to comment Share on other sites More sharing options...
jesh Posted April 12, 2007 Share Posted April 12, 2007 hm. Okay. It showed the url. Still not quite what I want it to do though. Can I use the variable in a link? (IE... <a href="$ref">Back</a> )?That sounds right. If $ref stores the URL to the previous page, then using something like this should work:echo '<a href="$ref">Back</a>'; Link to comment Share on other sites More sharing options...
The Praetorian Posted April 12, 2007 Author Share Posted April 12, 2007 Stupid wireless. Can delete this one. Link to comment Share on other sites More sharing options...
The Praetorian Posted April 12, 2007 Author Share Posted April 12, 2007 Okay. Friend of mine told me to do this, so I'll post it in case anyone else looks for it. (I used this in an echo, that's why the " are escaped.) <a href=\"java script:back()\">Back</a> Thanks for the help guys. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now