question about going back to a page
Moderator: General Moderators
question about going back to a page
hi guys,
what is the right code to use on a link to get the user to get directed back to the page they were just on.
for example, a shopping cart, they add item, goes to the shopping cart, now i want a link to go back to the page they were just on.
what should i look up to do this?
thanx.
what is the right code to use on a link to get the user to get directed back to the page they were just on.
for example, a shopping cart, they add item, goes to the shopping cart, now i want a link to go back to the page they were just on.
what should i look up to do this?
thanx.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
test.php:
test2.php:
Ask if you still have questions..
Code: Select all
<?php
session_start();
$filename = "test.php";
$last = $_SESSION['last'];
$_SESSION['last'] = $filename;
echo "<a href="test2.php">Go Foward</a>";
echo "<a href="" .$last. "">Go back</a>";
?>Code: Select all
<?php
session_start();
$filename = "test2.php";
$last = $_SESSION['last'];
$_SESSION['last'] = $filename;
echo "<a href="test3.php">Go Foward</a>";
echo "<a href="" .$last. "">Go back</a>";
?>At http://www.tonymarston.net/php-mysql/ba ... blues.html you can find some inspiration at 2-) Maintain a program stack.
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
Code: Select all
$_SERVER['HTTP_REFERER'];http_referer does not always work.
Code: Select all
function geturl()
{
$ports = array('https' => 443, 'http' => 80);
$prefix = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$url = $prefix;
$url .= $_SERVER['SERVER_PORT'] != $ports[$prefix] ? ':' . $_SERVER['SERVER_PORT'] : '';
$url .= '://';
$url .= $_SERVER['HTTP_HOST'];
$url .= $_SERVER['REQUEST_URI'];
return $url;
}
echo geturl();