thinkphp 后台登陆验证

<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(&quot;testadmin&quot;);<br /> import(<a href="mailto:'@.ORG.Session'">'@.ORG.Session'</a>);<br /> if ($Form-&gt;create()) {</p> <p>$Dao = M(&quot;testadmin&quot;);// 实例化模型类<br /> // 构建写入的数据数组<br /> $username = addslashes($_POST['username']);<br /> $password=md5($_POST['password']);</p> <p> // 写入数据<br /> $List = $Dao-&gt;where(&quot;username='$username'&quot;)-&gt;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-&gt;assign(&quot;jumpUrl&quot;,&quot;main&quot;);<br /> $this-&gt;success(&quot;登陆成功&quot;);<br /> }else{<br /> $this-&gt;error('密码错误!');<br /> }<br /> } else {<br /> $this-&gt;error('用户名错误!');<br /> }<br /> } else {<br /> header(&quot;Content-Type:text/html; charset=utf-8&quot;);<br /> exit($Form-&gt;getError() . ' [ <a href="javascript:history.back()">返 回</a> ]');<br /> }<br /> }</p>
RangeTime:0.006568s
RangeMem:205.27 KB
返回顶部 留言