<?php
public
function
checkyzm(
$yzm
){
$verify
=
new
\Think\Verify();
if
(
$verify
->check(
$yzm
)){
return
true;
}
else
{
echo
'验证码错误';
exit
();
}
}
public
function
login(){
if
(!IS_POST){
$this
->display();
}
else
{
if
(
$this
->checkyzm(I('post.yzm'))){
$username
=I('post.username');
$user
=D( ' user ' )->where(
" username='$username' "
)->find();
if
(md5( I( ' post.password ' ) .
$user
[ ' salt ' ])===
$user
['password']{
cookie('username' ,
$userp
[ ' username ' ]);
$this
->redirect('/');
}
else
{
echo
'用户名或密码不对';
}
}
}
}
您好欢迎观临
<
if
condition=
"$Think.cookie.username eq null"
>
<a href=
"{:U('Home/User/login')}"
rel=
"external nofollow"
rel=
"external nofollow"
style=
"color:#50884b"
>登陆</a> |
<a href=
"{:U('Home/User/reg')}"
rel=
"external nofollow"
style=
"color:#50884b"
>免费注册</a> |
<
else
/>
{
$Think
.cookie.username}|
<<a href=
"{:U('Home/User/login')}"
rel=
"external nofollow"
rel=
"external nofollow"
style=
"color:#50884b"
>退出</a>
</
if
>
public
function
logout(){
cookie('username' , null);
$this
->redirect('/');
}
?>}