From: "Deependra B. Tandukar" <[EMAIL PROTECTED]>
> Greetings!
>
> Is there any equivalent code for (JavaScript) <a
> href=JavaScript:history-back(1)>Back Button</a> in php?
>
> This works as back button on the menu bar.
>
> Looking forward to hearing from you.
>
> regards,
> DT
>
>
Yes, but it works differently. If the user typed in the URL of your page
(instead of clicking a link) then you can't go back from PHP, so you need to
be careful. Here's some sample code:
<?php
$referer = getenv("HTTP_REFERER");
if ($referer)
{
$url = $referer;
}
else
{
// can't go back... try JS instead
$url = "javascript:history.back()";
}
echo "<a href=\"$url\">Back Button</a>";
?>
Cheers
Simon Garner
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]