Home > Article > Backend Development > How to use thinkphp to log in with mobile phone number and user name at the same time
This article mainly introduces the method of logging in with mobile phone number and user name at the same time. It has certain reference value, let’s take a look at it together
Without further ado, please look at the code:
//在注册时用户名不能是纯数字, 防止一个人的用户名和另一个人的手机号相同 public function Login(){ if (IS_AJAX) { $username = I('param.username'); //var_dump($username); $password = I('param.password'); $user = M("cuser"); $res=$user->where("login_id='{$username}' OR phone='{$username}'")->find(); if (!empty($res) && $res['password']==md5($password)) { $status=1; //用户名正确,密码正确。 }elseif(!empty($res) && $res['password']!==md5($password)){ $status=2; //用户名正确,密码不正确。 }elseif(empty($res)){ $status=3; //用户名不存在。 } $this->ajaxReturn($status); exit(); } $mobile = parent::isMobile(); if($mobile=="true"){ $this->display(Wap_Login); }else{ $this->display(Login); } }##The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website! Related recommendations:
About Thinkphp’s function code for SMS verification registration
Thinkphp framework implements login, registration, Password retrieval function code
#
The above is the detailed content of How to use thinkphp to log in with mobile phone number and user name at the same time. For more information, please follow other related articles on the PHP Chinese website!