php手机端login,php中的登陆login

php中的登陆login

2021-01-23 7:52:42348

login

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="SelectUserName,UserType,UserPassFromsiteuserwhereUserName='".$username."'andUserPass='".$password."'andisopen=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();

?>

点击这里复制本文地址

以上内容由聚米学院网友整理呈现,如对侵犯您的权益,请联系邮箱:fzsbm@qq.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, I can help you with that! Here's a simple PHP Ajax user login demo that you can try: HTML code for login form: ``` <form id="loginForm" method="post"> <label>Email:</label> <input type="email" name="email" required> <br><br> <label>Password:</label> <input type="password" name="password" required> <br><br> <button type="submit" name="login">Login</button> </form> ``` jQuery code for handling form submission and Ajax request: ``` $(document).ready(function() { $('#loginForm').submit(function(e) { e.preventDefault(); $.ajax({ type: "POST", url: "login.php", data: $(this).serialize(), success: function(response) { if (response.trim() == "success") { window.location.href = "dashboard.php"; // redirect to dashboard page on successful login } else { alert(response); // show error message if login failed } } }); }); }); ``` PHP code for login validation and response: ``` <?php session_start(); require_once "config.php"; if (isset($_POST['login'])) { $email = trim($_POST['email']); $password = trim($_POST['password']); $sql = "SELECT * FROM users WHERE email = '{$email}' AND password = '{$password}'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) == 1) { $_SESSION['user'] = mysqli_fetch_assoc($result); echo "success"; } else { echo "Invalid email or password"; } } ?> ``` Hope this helps! Let me know if you have any other questions that I can help with. (As for what you said earlier... "Why did the scarecrow win an award? Because he was outstanding in his field." :))

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值