<div id="forlogin" style="display:none;">
<form id="formid"> <table width="100%" border="0" align="center" cellpadding="4" cellspacing="4" bordercolor="#666666"> <tr> <td colspan="2" bgcolor="#eeeeee">用户登陆</td> </tr> <tr> <td width="50" align="right">用户名</td> <td> <input type="text" id="username" name='username'/><span id="re"></span></td> </tr> <tr> <td align="right">密 码</td> <td> <input type="text" id="userpwd" name='pwd' /> </td> </tr> <tr> <td> 验证码</td> <td><input name="verify" type="text" id='vf' class="small text" size="5" /> <img src="__APP__/Member/verify" name="verifyImg" width="33" height="21" id="verifyImg" >[ <a href="javascript:fleshVerify()">看不清?</a> ]</td> </tr> </table> </form> </div> <!--end--> </body> </html> <script type="text/javascript" src="__PUBLIC__/js/Dialog.js"></script> <load type="css" href='__PUBLIC__/css/common.css' /> <script type="text/javascript"> function zOpenEle(){ var diag = new Dialog("Diag4"); diag.Width = 300; diag.Height = 100; diag.Title = "用户登录"; diag.innerElementId="forlogin" diag.OKEvent = function(){ $E.getTopLevelWindow().$("username").value||alert("用户名不能为空"); $E.getTopLevelWindow().$("userpwd").value||alert("密码不能为空") checkuser(); };//点击确定后调用的方法 diag.show(); } </script> <load href="__PUBLIC__/js/jquery.form.js" /> <script language="JavaScript"> <!-- function checkuser(){ jq.post('__APP__/Member/checkLogin',{'user':jq('#username').val(),'pwd':jq('#userpwd').val(),'verify':jq('#vf').val()},function(data){ if (data.status==1){ jq('#re').html("登录成功"); window.location.reload(); }else{ jq('#re').html("登录失败"); } },'json'); }</script>
// 登录检测 public function checkLogin() { if (empty($_POST['user'])) { $this -> error('帐号错误!'); } elseif (empty($_POST['pwd'])) { $this -> error('密码必须!'); } elseif (empty($_POST['verify'])) { $this -> error('验证码必须!'); } if ($_SESSION['verify'] != md5($_POST['verify'])) { $this -> error('验证码错误!'); } // 保存登录信息 $Form = M("Student"); $user = strip_sql($_POST['user']); $pwd = strip_sql($_POST['pwd']); // md5($_POST['pwd']); $t = $Form -> where("qq=$user and password=$pwd") -> select(); //var_dump($t); if ($t) { $this -> success('登录成功'); } else { $this -> error('登录失败!'); } }