当前位置: 移动技术网 > IT编程>开发语言>PHP > php中的登陆login

php中的登陆login

2019年05月15日  | 移动技术网IT编程  | 我要评论
login
<?php
require "../include/dbclass.php";
$username=$_post['username'];
$password=$_post['password'];
if(empty($username) || empty($password)){
  go_msg("请填写用户名,密码!","../default.html");
  exit;
 }
dbconn();
$password=md5($password);
$sql = "select username,usertype,userpass from siteuser where username='" . $username ."' and userpass='" . $password . "' and isopen=1";
//echo "$sql";
$result = $db -> exec_sql($sql);
 $total=mysql_num_rows($result);
 if($total==0){
  dbclose();
  go_msg("注册用户还没有通过管理员审核或用户名及密码不符!请重新输入!","../default.html");
  exit;
 }else{
  $rs = $db -> fetch_array($result);
  //附值,并登录
  session_register("username");
  session_register("usertype");
  $_session["usertype"]=$rs['usertype'];
  $_session["username"]=$username;
  //echo $_session["username"];
  if ($_session["usertype"]==1){
    go_msg("登陆成功!","default.php");

    //header('location:http://163.com');
  }
  if ($_session["usertype"]==2){
     go_msg("登陆成功!","../user2/default_1.php");
  }
  if ($_session["usertype"]==3){

     go_msg("登陆成功!","../user3/default_2.php");
  }
  // header('location:default.php');
 }
dbclose();

?> 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网