<p>thinkphp 后台登陆验证</p>
<p>测试地址:<a href="http://www.seocn.info/web/thinkmsg/Admin"><span ><span ><span >http://www.seocn.info/web/thinkmsg/Admin</span></span></span></a></p>
<p></p>
<p>用户名:<span ><span ><span >test</span></span></span></p>
<p>密码:<span ><span ><span >test</span></span></span></p>
<p><img alt="" src="/up_pic/201211/20121104111122.jpg" /></p>
<p></p>
<p><img alt="" src="/up_pic/201211/20121104111137.jpg" /></p>
<p>function login()<br />
{<br />
$Form = D("testadmin");<br />
import(<a href="mailto:'@.ORG.Session'">'@.ORG.Session'</a>);<br />
if ($Form->create()) {</p>
<p>$Dao = M("testadmin");// 实例化模型类<br />
// 构建写入的数据数组<br />
$username = addslashes($_POST['username']);<br />
$password=md5($_POST['password']);</p>
<p> // 写入数据<br />
$List = $Dao->where("username='$username'")->find();<br />
if(is_array($List)){<br />
$code=$List['urand'];<br />
$password=md5($password.$code);<br />
if($password==$List['password'])<br />
{<br />
setcookie('username',$username);<br />
setcookie('password',$password);<br />
$this->assign("jumpUrl","main");<br />
$this->success("登陆成功");<br />
}else{<br />
$this->error('密码错误!');<br />
}<br />
} else {<br />
$this->error('用户名错误!');<br />
}<br />
} else {<br />
header("Content-Type:text/html; charset=utf-8");<br />
exit($Form->getError() . ' [ <a href="javascript:history.back()">返 回</a> ]');<br />
}<br />
}</p>