【PHP】简单的登陆验证和权限管理

一、登录页面


二、登陆验证

check.php

location.href='index.php';";}
?>

include.php


mysql.php

ERROR'.mysql_errno().':'.mysql_error());
    //字符集
    //mysql_set_charset(DB_CHARSET,$link);
    mysql_query("SET NAMES 'utf8'");
    //打开数据库
    mysql_select_db(DB_DBNAME) or die ('指定的实据库打开失败');
    return $link;
}
/*
 * 查询一条记录
 *
 *  */
 
function feachOne($sql,$result_type=MYSQL_ASSOC){
    $result=mysql_query($sql);
    if($result && mysql_num_rows($result)>0){
        return mysql_fetch_array($result,$result_type);
    }else{
        return false;
    }
}
 
?>

config.php



三、session权限验证(index.php)

power.php

在后面需要登录才能查看的页面和需要权限的页面include此文件

location.href='login.php';";
}elseif($_SESSION[‘power’]<=’10’){
 echo “您没有权限查看此页!”;
}


index.php(后缀名为php才可以直接使用)


?>


你可能感兴趣的:(简单PHP)