mysql与php、会话多级用户身份验证和页面

mysql与php、会话多级用户身份验证和页面,php,mysql,session,Php,Mysql,Session,我试图实现我自己的类、函数和视图,用php、mysql和pdo类实现多用户身份验证和页面 请让我知道我是以正确的方式做的,还是走错了路 Mysql表将如下所示: userID-----------int 1 userName---------varchar abc userPassword-----varchar pass userAccessCode---int 100 这是html和php,它将通过po

我试图实现我自己的类、函数和视图,用php、mysql和pdo类实现多用户身份验证和页面

请让我知道我是以正确的方式做的,还是走错了路

Mysql表将如下所示:

userID-----------int              1
userName---------varchar          abc
userPassword-----varchar          pass
userAccessCode---int              100
这是html和php,它将通过post将数据传递给authen类中名为(aut)的函数

注意:会话将在标头登录中启动。并在注销时关闭

      //include authen class
      if(isset(POST){
            $authen->name= Check_Params($_POST['name ']);
            $authen->pass= Check_Params($_POST['pass']);
            $authen->accs= Check_Params($_POST['accs']);
            $authen->aut()
       }

    <form method="post">
    <input name="name" type="text">
    <input name="pass" type="password">
    <input name="access" type="password">
    <input type="submit" value="login">
    </form>
现在,在每个页面中,这将检查它是否是登录请求,这里是ifitislogin函数

public function ifitislogin() {
        if ($_SESSION['name'] == '' | $_SESSION['accs'] == '') {
            header("location:logout.php");
        } else {
            $accs = Check_Params(preg_replace('#[^0-9]#i', '', $_SESSION["accs"]));
            $name = Check_Params(preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["name"]));
            $stm = "SELECT COUNT(*) FROM userTBL WHERE `userName`=:name AND `userAccessCode`=:accs";
            stm = $this->conn->prepare($stmt9);
            $stm->bindParam(':nameo', $name);
            $stm->bindParam(':accs', $accs);
            $stm->execute();
            $checkstm = $stm->fetchColumn();
            if ($checkstm != 1) {
                header("location:logout.php");
                exit();
            }
        }
    }
例如,这是所有人的索引页:

//include class authentic
    $authen->ifitislogin();   // this will check if user is valid:



    echo "<h1>" welcome to the document management system</h1> <br/>";

    //this will befor admin and operator 
    if($_SESSION['accs'] = Check_Params('100')){
            echo "<h1>welcome to admin page data....</h1>";
    } elseif($_SESSION['accs']) == 101) {
           echo "<h1>welcome to reporter page data....</h1>"
    } else {
            echo "welcome msg";
    }

    //this will be for clients or users, the function will get the result from database based on the user name and accs/        
    $accs = Check_Params($_SESSION['accs']);
    $name = Check_Params($_SESSION['name']);   
    //get the result from database based on these tow variable which means $accs, $name it will select from database base where access = $accs and name = $name
//包含类authentic
$authen->ifitislogin();//这将检查用户是否有效:
echo“欢迎使用文档管理系统
”; //这将交给管理员和操作员 如果($\会话['accs']=检查参数('100')){ echo“欢迎使用管理页面数据…”; }elseif($_会话['accs'])==101){ echo“欢迎访问记者页面数据…” }否则{ 回声“欢迎消息”; } //这将适用于客户端或用户,函数将根据用户名和accs/从数据库中获取结果 $accs=检查参数($会话['accs']); $name=检查参数($\会话['name']); //根据这两个变量从数据库中获取结果,这两个变量表示$accs,$name,它将从数据库中选择,其中access=$accs和name=$name
在这个代码部分中,根据我从会话变量中获得的数据查询数据库中的数据,是否可以?如果不可以,我如何知道哪些数据应该显示给哪个用户?或者哪个页面应该显示给哪个用户


关于预付款。

制作一个两页的页面,其中一页只显示给注册用户,另一页将显示不是您页面成员的用户。我不想注册任何用户,这是唯一一个用户可访问的web应用程序,我在做会话管理是否正确,是否安全,我正在使用ssl制作一个两页的页面,这将是只显示注册用户和一个将显示不是您页面成员的用户。我不想注册任何用户,它只是用户可访问的web应用,我在这里做会话管理是否正确,是否安全,我也在使用ssl
//include class authentic
    $authen->ifitislogin();   // this will check if user is valid:



    echo "<h1>" welcome to the document management system</h1> <br/>";

    //this will befor admin and operator 
    if($_SESSION['accs'] = Check_Params('100')){
            echo "<h1>welcome to admin page data....</h1>";
    } elseif($_SESSION['accs']) == 101) {
           echo "<h1>welcome to reporter page data....</h1>"
    } else {
            echo "welcome msg";
    }

    //this will be for clients or users, the function will get the result from database based on the user name and accs/        
    $accs = Check_Params($_SESSION['accs']);
    $name = Check_Params($_SESSION['name']);   
    //get the result from database based on these tow variable which means $accs, $name it will select from database base where access = $accs and name = $name