Re: Previous page ..
| From: | Justin French | Date: | Wed, 23 Aug 2000 03:37:58 +0000 |
| Subject: | Re: Previous page .. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13071@lists.php.net to get a copy of this message | ||
Christian wrote:
> I'm not sure if the follow problem is
> PHP, Apache, Javascript or a browser problem ..
> So sorry if it's a little off topic ..
>
> I have a PHP page containing links to another page ...
> I pass through a variable .. eg. secondPage.php?id=88
>
> On the following page I have a back button ..
> At the moment it is an image in a form ..
> Now on click or submit I've called
> history.back() and history.previous etc ...
>
> Instead of going back to the previous page ..
> It is calling the same page (secondPage.php?x=45&Y=64)
> and setting variables of it's own X and Y ...
>
> Why is it not going back to the previous page (firstPage.php)
> And what are X and Y ?
Christian, Aaron,
Instead of relying on JavaScript (which requires the user to HAVE IT),
why not rely on PHP by itself??
<!-- untested code :) -->
<?php
$backlink = $HTTP_REFERER;
echo "<A HREF=\"".$backlink."\">Click here to go
back</a>";
?>
or, if the person arrives at the page directly (with a referrer), you
could NOT display any of the line :)
<!-- untested code :) -->
<?php
$backlink = $HTTP_REFERER;
if ($backlink != "") {
echo "<A HREF=\"".$backlink."\">Click here to go
back</a>";
} else {
echo " ";
}
?>
You won't need to pass any variables into the following page at all.
Justin French