Home >php教程 >PHP源码 >php数据库连接之权限配置

php数据库连接之权限配置

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:25:061607browse

虽然是说简单的数据库连接代码,但最终是来判断用户权限的,有需要的朋友可以参考一下。

<script>ec(2);</script>
 代码如下 复制代码

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']             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();
    }

}
?>

Statement:
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