SoFunction
Updated on 2025-03-10

thinkphp mobile phone number and username log in at the same time

Without further ado, please see the code:

//The username cannot be a pure number when registering, to prevent one person's username from being the same as another person's mobile phone numberpublic function Login(){
 if (IS_AJAX) {
 $username = I('');
 //var_dump($username);
 $password = I('');
 $user = M("cuser");
 $res=$user->where("login_id='{$username}' OR phone='{$username}'")->find();
 if (!empty($res) && $res['password']==md5($password)) {
 $status=1; //The user name is correct and the password is correct. }elseif(!empty($res) && $res['password']!==md5($password)){
 $status=2; //The user name is correct and the password is incorrect. }elseif(empty($res)){
 $status=3; //The user name does not exist. }
 $this->ajaxReturn($status);
 exit();
 }
 $mobile = parent::isMobile();
 if($mobile=="true"){
 $this->display(Wap_Login);
 }else{
 $this->display(Login);
 } 
 }

The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!