PHP+MYSQL会员系统的登陆即权限判断实现代码
前端之家收集整理的这篇文章主要介绍了
PHP+MYSQL会员系统的登陆即权限判断实现代码,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<div class="codetitle"><a style="CURSOR: pointer" data="37528" class="copybut" id="copybut37528" onclick="doCopy('code37528')"> 代码如下:
<div class="codebody" id="code37528">
<?
PHP error_reporting(0);
session_start();
//
数据库连接
$conn =
MysqL_connect('localhost','root','');
MysqL_select_db('chenkun',$conn);
MysqL_query('SET NAMES UTF-8');
//定义常量
define('ALL_PS','
PHP');
function user_shell($uid,$shell,$m_id) {
$
sql = "select * from admin where uid='$uid'";
$query =
MysqL_query($
sql);
$row =
MysqL_fetch_array($query);
$shell = is_array($row) ? $shell == md5($row['username'] . $row['password'] . ALL_PS) : FALSE;
if ($shell) {
if ($row['m_id'] <= $m_id) {
return $row;
}
echo "你的权限不足";
exit ();
} else {
echo "你无权限访问该页";
exit ();
}
}
function user_mktime($onlinetime) {
$new_time = mktime();
if (($new_time - $onlinetime) > '900') {
session_destroy();
echo "登陆超时";
exit ();
} else {
$_SESSION['times'] = mktime();
}
}
?>
config.