php实时检测用户名和密码是否正确并提示
php实时检测⽤户名和密码是否正确并提⽰
静态页代码:
qq名片背景<style>
#login{width: 250px;height: 120px;background-color: aquamarine;position: fixed;top: 0px;left: 0px;right: 0px;bottom: 0px;margin: auto;padding:50px;text-align: left;}
</style>
<script type="text/javascript" src="__PUBLIC__/js/jquery-3.2.1.js"></script>
<script type="text/javascript">
function rusername(obj){
var username=$(obj).val();
$.post("{:U('Login/lusername')}",{username:username},function(data) {
$("#username").html(data)
})
}
function rpassword(obj){
var password=$(obj).val();
$.post("{:U('Login/lpassword')}",{username:password},function(data) {
$("#password").html(data)
})
}
</script>
<div id="login">
<form action="__ACTION__" method="post">
<p><input name="username" type="text" value="" size="25" placeholder="填写⽤户名" onblur="rusername(this);"/><br/><span id="username" ></span></p>    <p><input name="password" type="password" value="" size="25" placeholder="输⼊密码" onblur="rpassword(this);"/><br/><span id="password" ></span></p>    <p><input name="submit" type="submit" value="登录"/>
       
       
       
<input name="submit" type="submit" value="注册"/>
情人节发朋友圈说说</p>
</form>
</div>
控制器代码:
<?php
namespace Home\Controller;
use Think\Controller;
拉杆箱排名class LoginController extends Controller {
public function login(){
if($_POST){qq描述
$where['username']=$_POST['username'];
$where['password']=md5("php100".$_POST['password']);
$users=M('users')->where($where)->select();
if($users){
$_SESSION['id']=$users['id'];
$_SESSION['user_shell']=md5($users['username'].$users['password']);
$this->redirect('Index/index');
}else{
echo "<script type='text/javascript'>alert('⽤户名或密码错误');(-1);</script>";
}
}else{
$this->display();
}
}
public function lusername(){
$where['username']=I('username');
$users=M('users')->where($where)->select();
if(!$users){
echo "⽤户名错误";
全国宜居城市排行
}
}
public function lpassword(){
$where['password']=I('password');
$users=M('users')->where($where)->select();
if(!$users){
echo "密码错误";
oppoa11
}
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。