Posts filed under 'PHP'

Back Link

Do people really click on their browser’s back icon? Yes, they probably do. Would adding a link that brings a user back to the previous page a smart idea? Yes, maybe it is a smart idea. The reason is because in most occasion the user’s mouse pointer would usually be around the area of the page but not at the top left hand corner of the browser. Therefore, a back link on the page makes going back to the previous page much easier. Below is a short code snippet that I have been using if I am to write a PHP script on my own and I think it is very effective.

if (isset($HTTP_REFERER)) {
echo “<a href=’$HTTP_REFERER’>Back</a>”;
} else {
echo “<a href=’javascript:history.back()’>Back</a>”;
}

The above PHP code basically says that if the predefined variable HTTP_REFERER is set, then print a back link to the previous page, else use the java script method history.back(). Simple as that and it is fun.

Add comment May 9th, 2006


 

March 2010
M T W T F S S
« May    
1234567
891011121314
15161718192021
22232425262728
293031  

Pages

Blogroll

Categories