>백엔드 개발 >PHP 튜토리얼 >php与数据库相关重要有关问题求解答

php与数据库相关重要有关问题求解答

WBOY
WBOY원래의
2016-06-13 10:23:491054검색

php与数据库相关重要问题求解答
各位前辈高人,我在login.html中点击登录后直接转向userController.php,并且不显示任何东西,我的目的是验证登录成功后直接跳到mian.html 不成功则跳到error.html中,可是不成功,请问我哪里错了,还有一个问题就是登录成功后怎么吧登录者的信息传给mian.html?谢谢了


PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> login.html    <title>用户系统登录</title>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
角色 管理员 教师 学生
用户名
密码
新用户注册

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->dbconn.class.php<?php class DBconn{        private static $db_host="localhost";        private static $db_user="root";        private static $db_password="linux";        private static $db_name="sharewebDb";        private static $connection;        static function getConn(){            $connection=new mysqli($db_host,$db_user,password,$db_name);            return $connection;        }        }?>

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->userModel.php<?php include("dbconn.class,php");class userModel{    function checklogin($userid,$userpwd,$useraccount){        $mysqli=DBconn::getConn();        $result='';        switch($useraccount){        case "teacher":{                $sql="select t_id,t_name,t_dep from ter_info where t_id=? and t_pwd=?";                $result=$mysqli->prepare($sql);:                $result->bind_param("ss",$user_id,$user_password);                $user_id=$userid;                $user_password=$userpwd;                $result->execute();break;                }        case "student":{                $sql="select s_id,s_name,s_dep from stu_info where s_id=? ands_pwd=?";                $result=$mysqli->prepare($sql);                $result->bind_param("ss",$user_id,$user_password);                $user_id=$userid;                $user_password=$userpwd;                $result->execute();break;                }        }        $result->bind_result($user_id,$user_name,$user_dep);        while($result->fetch()){            $userlist=array(                'user_id'=>$user_id,                'user_name'=>$user_name,                'user_dep'=>$user_dep            );                }        $result->close();        $mysqli->close();        return userlist;    }?><div class="clear">
                 
              
              
        
            </div>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.