Previous URL

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>previous</title>
</head>
<body>
<a href="next.php">next</a>
</body>
</html>

If you click the the link next in http://dot.kr/x-test/previous.php which has the code above, it will go to next.php.

I like to get the previous URL at next.php .

[b]would-be code[/b]

<?php
echo $referer
?>

How can I make the would-be code above to work fine for getting the previous URL or previous file name (previous.php).

$_server['http_referer'];

I have the code below.

[b]previous1[/b]

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>previous1</title>
</head>
<body>
 
<a href="next1.php">next1</a>

</body>
</html>

[b]next1[/b]

<!doctype html>
<html> 
  <head>
    <meta charset="UTF-8">
    <title>next1</title>
</head>
<body>
 
<?php
[COLOR="Red"]echo $_server['http_referer'];[/COLOR]
?>

</body>
</html>

If you click the link nex1.php in http://dot.kr/x-test/previous1.php, it will go to http://dot.kr/x-test/next1.php .

Although I am expecting the next1.php shows the previous URL or previous file name. It shows nothing but blank.

Sorry, I meant

$_SERVER['HTTP_REFERER'];

Bear in mind that browsers don’t always send this value, and it can be faked. Don’t depend on it! If this is just for internal links, you may want to store the last page the user viewed so you know for sure… though browsers generally come with a back button for this?