首页 > php教程 > PHP源码 > 正文

登录验证新思路,演示登录代码.

PHP中文网
发布: 2016-05-25 17:00:15
原创
1118 人浏览过

需要用到 jquery 以及 md5 相关javascrip方法. 代码中直接引用了外部链接. 如果运行出现状况, 请单独下载,修改代码.

演示数据只有一个用户 id:test. passwd:abc123. 用文本存放数据. 简单演示. 喜欢记得收藏, 转载请注明出处.

$mstr, 'str'=>$str));
exit;
}


if(isset($_POST['id'])) {

$st = false;
$ua = get_u_i();
if($id && ($ua['id'] == $id) && (md5($ua['passwd'].$ua['str']) == $passwd)) {
$st=true;
}
if($st) { 
$ua['str'] = dechex(get_hstr());
set_u_i($ua); 
echo <<



test login

胜利大联欢. EOT; } else { } exit; } $ua = array('id'=>'test', 'passwd'=>md5('abc123'), 'str'=>''); set_u_i($ua); function get_mstr() { $t = explode(' ', microtime()); $time = $t[0] * 1000; $time = intval($time); //$time = dechex($time); return $time; } function get_hstr() { $h_max = H_MAX; return mt_rand(0, $h_max); } function get_u_i() { $file = 'test_login.txt'; $str = file_get_contents($file); $str = trim($str); @list($id, $passwd, $str) = explode("t", $str); return array('id'=>$id, 'passwd'=>$passwd, 'str'=>$str); } function set_u_i($ua) { $file = 'test_login.txt'; file_put_contents($file,implode("t", $ua)); } ?> test login
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!