<!-- index.htm -->
<a href=test.php>test</a><?php
//test.php
if($_SERVER['HTTP_REFERER'] == "http://localhost/php/index.htm"){
echo "来自于 http://localhost/php/index.htm ";
}else{
echo "hello world!";
}
?>
<a href=test.php>test</a><?php
//test.php
if($_SERVER['HTTP_REFERER'] == "http://localhost/php/index.htm"){
echo "来自于 http://localhost/php/index.htm ";
}else{
echo "hello world!";
}
?>
方法二:echo "<script>window.location =\"$PHP_SELF\";</script>";
方法三:echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=index.php\">"; <?php
//test.php
if($_SERVER['HTTP_REFERER'] == "http://localhost/php/index.htm"){
echo "<script>window.location =\"http://xx.com/a.zip\";</script>";
}else{
echo "hello world!";
}
?>
这样的话怎样让用户点击了下载连接以后和点击一个exe文件一样,直接弹出下载窗口?
<?php
if($_GET['step'] and $_GET['step']=="down"){
echo "<script>window.location =\"http://xxx.com/test.exe\";</script>";
exit;
}
echo "<a href=http://xxx.com/test.exe>点击下载</a>";
莫非只能在target=_blank里面实现?
方法二:echo "<script>window.location =\"$PHP_SELF\";</script>";
方法三:echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=index.php\">";
偶喜欢用第二种。
解释的够详细。
学习ing……
download.php?id=xxx
这种链接在接收到$_GET['id']来的值后可以查询数据库中id=$_GET['id']的结果中的http://xx.com/a.exe等地址字段,再进行输出处理的。
第一,你喜欢用的echo "<script>window.location =\"http://xx.com/a.exe\";</script>";无法弹出新窗口,这样原来的窗口就给替换了。
第二, if($_SERVER['HTTP_REFERER'] == "http://soft.soulsky.net")好像没用。没有被确认。
莫非只能在target=_blank里面实现?不是希望直接打开窗口下载的吗?还要返回什么好累:)
$_SERVER['HTTP_REFERER']搞定,原来最后还要加上一个/