There are many ways to pass data:
Your value:
<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>
Forms hidden input field (POST | GET)
<form method="POST" action="page2.php">
<input type="hidden" name="url" value="<?php echo $url;?>">
<p><input type="submit" value="Submit"></p>
</form>
Change method="POST"
to method="GET"
for GET
A Link (GET)
<a href="page2.php?url=<?php echo urlencode($url);?>">Download</a>
Through a session
<?php
session_start(); //First line of page1 and page2
$_SESSION['url']=$url;
?>
Then to get the value use the globals $_POST
and $_GET
or $_SESSION
depending on which method you choose.
Even webstorage javascript (HTML5):
<div id="result"></div>
<script type="text/javascript">
if(typeof(Storage)!=="undefined")
{
if (localStorage.passthis){
//Already set, perhaps set it here on page1 and and display it here on page2
}
else{ //Not set
localStorage.passthis = window.location.href;
}
document.getElementById("result").innerHTML="Passed from page1.php: " + localStorage.passthis;
}else{
//No web storage
}
</script>
Hope it helps, I suggest you do alittle research first before asking a question. php.net is your friend.