传递数据的方式有很多:
你的价值:
<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>
表单隐藏输入字段(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>
更改method="POST"
为method="GET"
GET
链接 (GET)
<a href="page2.php?url=<?php echo urlencode($url);?>">Download</a>
通过会话
<?php
session_start(); //First line of page1 and page2
$_SESSION['url']=$url;
?>
然后根据您选择的方法使用全局变量或获取值$_POST
。$_GET
$_SESSION
甚至网络存储 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>
希望对您有所帮助,我建议您在提问之前先进行一些研究。php.net是你的朋友。