php中的登陆login
程序员文章站
2022-04-28 14:21:15
login
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();
?>
<?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();
?>
下一篇: 如何把PHP转成EXE文件