tp5 用戶注冊;登錄


public function work_login_add()
{
/*添加用戶*/
$names=$_POST["names"];
$user=$_POST["user"];
$pwd=$_POST["pwd"];
$pwd=base64_encode($pwd);
$res=Db::name("Workuser")->insert(['u_name'=>$names,'u_username'=>$user,'u_password'=>$pwd]);
return json(['data'=>$names,'msg'=>"添加成功"]);
}
public function work_login()
{ /*用戶登錄*/
$user=$_POST["user"];
$pwd=$_POST["pwd"];
$pwd=base64_encode($pwd);
$floor=floor(microtime()*1000);
$names=Db::name("Workuser")->where(['u_username'=>$user,'u_password'=>$pwd])->value('u_name');
if($names){
$token=base64_encode($names.$floor);
$tokens=Db::name("Workuser")->where(['u_username'=>$user,'u_password'=>$pwd])->update(["u_token"=>$token]);
$u_status=Db::name("Workuser")->where(['u_username'=>$user,'u_password'=>$pwd])->value('u_status');
return json(['msg'=>"登錄成功",'token'=>$token,'u_status'=>$u_status]);
}else{
return json(['msg'=>"登錄失敗"]);
}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM