本文实例为大家分享了php中的登陆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();
// 何问起 hovertree.com
?>
以上就是本文的全部内容,希望对大家学习php程序设计有所帮助。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!