时间:2021-11-17 作者:Thinkphp 分类: 无
视图部分
<form action="__URL__/Udenglu" method="post" enctype="multipart/form-data">
<input name="action" value="login" type="hidden">
<input name="useremails" placeholder="登录邮箱" required="" type="text">
<hr class="hr15">
<input name="userpaswords" placeholder="密码" required="" type="password">
<hr class="hr15">
<input value="登录" style="width:100%;" type="submit">
<hr class="hr20">
帮助 <a onClick="alert('请联系管理员')">忘记密码</a>
</form>
php部分
public function Udenglu()//登录执行
{
$usersif = Db::name('users')->where(['useremails'=>input('post.useremails'),'userpaswords'=>input('post.userpaswords')] )->find();
if(count($usersif) < 1 ){
$this->error('抱歉,您的登录邮箱不存在或者错误,请重新登录!');
exit;
}else{
Session::set('uid',$usersif['Id']);
Session::set('usernames',$usersif['usernames']);
Session::set('useremails',$usersif['useremails']);
或者
session('user',$usersif)
$this->success('登录成功', '__ROOT__/member/Index/');
}
}
需要注意的是: Session 会话,得放进去
标签: thinkphp