新手求助个PHP代码
还有十几天高中毕业了,我建了个班级网站,是PHP的整站(EMLOG3.5),想在访问网站前加个密码验证,要求不先通过密码就不能访问网站的任何页面,本来想用html写的不过在源代码中就能找到密码,形同虚设。想请高手帮帮忙,写出完整代码。尽可能的详述。马上就高考了,我也没时间钻研了!谢谢。我QQ253863198
------解决方案--------------------
在网站公共文件加:
<a style="color:#f60; text-decoration:underline;" title="php" href="https://www.php.cn/zt/15714.html" target="_blank">php</a>
<a style="color:#f60; text-decoration:underline;" title="session" href="https://www.php.cn/zt/17098.html" target="_blank">session</a>_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
请输入访问密码:<input name="webPassword"><input type="submit">
EOT;
exit;
}
?> <div class="clear"></div>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号