• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

php 搞代码 4年前 (2022-01-23) 11次浏览 已收录 0个评论

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

2本文来源gao!daima.com搞$代!码网

搞代gaodaima码谢了

PHP code

<!---ecms 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"/> <body><table width="100%" border="0 "><tr><td align="center " valign="middle ">    <table align="center">        <tr>            <th>角色</th>            <td>管理员                教师                学生            </td>        <tr>            <th>用户名</th>            <td></td>        </tr>        <tr>            <th>密码</th>            <td></td>        </tr>        <tr>            <td align="right" colspan="2">新用户注册<button type="submit" name="submit">登录</button></td>        </tr>    </table></td></tr></table>

PHP code

<!---ecms 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

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;    }?> 


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php与数据库相关重要有关问题求解答
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址