新手个PHP代码

WBOY
Release: 2016-06-13 10:09:06
Original
1098 people have browsed it

新手求助个PHP代码
还有十几天高中毕业了,我建了个班级网站,是PHP的整站(EMLOG3.5),想在访问网站前加个密码验证,要求不先通过密码就不能访问网站的任何页面,本来想用html写的不过在源代码中就能找到密码,形同虚设。想请高手帮帮忙,写出完整代码。尽可能的详述。马上就高考了,我也没时间钻研了!谢谢。我QQ253863198

------解决方案--------------------
在网站公共文件加:

PHP code
<?phpsession_set_cookie_params (0,'/','');session_name('S');session_save_path(dirname(__FILE__).'/session/');//保存session的目录,还目录要存在,并有读写权限session_cache_limiter('private, must-revalidate');session_start();$_WEBPASSWORD="123";$_POST['webPassword'] && $_SESSION['webPassword']=$_POST['webPassword'];if($_SESSION['webPassword']!=$_WEBPASSWORD){     print <<<EOT<form action='' method='POST'>请输入访问密码:<input name="webPassword"><input type="submit">     EOT;exit;}?><div class="clear">
                 
              
              
        
            </div>
Copy after login
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template