Home > php教程 > PHP源码 > body text

获取是否指定地址进来

PHP中文网
Release: 2016-05-25 17:03:52
Original
1128 people have browsed it

/************
**  获取是否指定地址进来
**  参数值为判断必须进来的来路  第二个值可以为空 为空进跳到第一个值的地址
**  返回值:无
*************/


如:登录页面login.html 要发送到login.php

首先有时候要判断有没有表单值进来 然后再进行下一步

这个代码也可以用来判断表单有没有传值进来

而且还可以做更多的防御攻击

/************
**获取是否指定地址进来
**参数值为判断必须进来的来路第二个值可以为空 为空进跳到第一个值的地址
**返回值:无
*************/

function Antecedents($url,$toUrl='1'){
if($toUrl==1){
$toUrl=$url;
}
$url=ltrim($url,"/");
$goUrl=$_SERVER['HTTP_REFERER'];
if($goUrl!=$url){
header("location:$toUrl");
}
}
Copy after login

                   

以上就是获取是否指定地址进来的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!