Perasaan peribadi tersedia, sila betulkan saya!
<?php session_start() ; //如果直接打开用户后台首页就判断阶段变量是否为空,如果为空就来到注册页面,如果不为空就进入首页 $sjh=$ _SESSION[ 'MM_UserNmae1']; if ($sjh !==n ull) { echo "<script>top.location='index.php';</script>"; exit; }?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>用户登录</title> <link href="../css/tou.css" rel="stylesheet" type="text/css"> <link href="../css/dibu.css" rel="stylesheet" type="text/css"></head> <body style="background-image:url(../ditu.png);background-attachment:fixed;background-color:#000;"> <?php require_once( '../header.php'); ?> <table width="444" height="272" border="1" align="center" cellpadding="0" cellspacing="0" style="font-size: 20px; color: #F5F5F5;"> <tbody> <tr> <td colspan="4" align="center" style="color: #EDEC0D"> <strong>用 户 登 录</strong></td> </tr> <tr> <td width="100" align="center"> <label for="sjh">手机:</label></td> <td colspan="2" align="center"> <input name="sjh" id="sjh" type="text" style="font-size: 18px;" size="16" maxlength="11" autofocus="" oninput="value=value.replace(/[^\d]/g,'')" placeholder="11位数手机号"></td> <td width="132"> <p id="s1" style="font-size: 14px;">请输入手机号</p></td> </tr> <tr> <td align="center"> <label for="mima">密码:</label></td> <td colspan="2" align="center"> <input name="mima" id="mima" type="text" style="font-size: 18px;" size="16" maxlength="8" onkeyup="this.value=this.value.replace(/[^\w_]/g,'');" placeholder="密码六到八位数"></td> <td> <p id="s2" style="font-size: 14px;">请输入密码</p></td> </tr> <tr> <td align="center"> <label for="yzm">验证码:</label></td> <td width="102" align="center"> <input name="yzm" id="yzm" type="text" style="font-size: 18px;" size="6" maxlength="4" onkeyup="this.value=this.value.replace(/[^\w_]/g,'');"></td> <td width="119" align="center"> <img src="yzm.php" alt="" width="100" height="30" onClick="this.src=this.src+'?'+Math.random()" /></td> <td> <p id="s5" style="font-size: 14px;">请输入验证码</p></td> </tr> <tr> <td colspan="4"> <input style="font-size: 20px; margin-left: 170px" name="submit" type="submit" value="点击登录" id="submit"> <span id="s6" style=" font-size: 14px;"></span> </td> </tr> </tbody> </table> <?php require_once( '../footer.php'); ?></body> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript">//失去焦点开始判断-手机号不足11位自动弹出警告且重新获取焦点 $("#sjh").blur(function(){ var p = $('#sjh').val(); if(p.length<11){ $("#s1").text("手机号不合法").css('color', 'red'); //setTimeout("$('#sjh').focus()",1); $('#sjh').focus() //不对头就移开当前焦点 }else{$("#s1").text("符合要求").css('color', 'green');} }); //失去焦点开始判断-密码不足6位自动弹出警告且重新获取焦点 $("#mima").blur(function(){ var p = $('#mima').val(); if(p.length<6){ $("#s2").text("密码不能够少于6位").css('color', 'red'); $('#mima').focus() }else{$("#s2").text("符合要求").css('color', 'green');} }); //失去焦点开始判断-确认验证码不足4位弹出提示框 $("#yzm").blur(function(){ var q = $('#yzm').val(); if(q.length<4){ $("#s5").text("验证码需4位数").css('color', 'red'); $('#yzm').focus(); }else{$("#s5").text("符合要求").css('color', 'green');} }); </script> <script type="text/javascript">$(document).ready(function() { $("#submit").click(function() { var a = $('#s1').text(); var b = $('#s2').text(); var e = $('#s5').text(); if (a == '符合要求' && b == '符合要求' && e == '符合要求') { //alert('符合要求'); $.post("reg11.php",{ sjh:$('#sjh').val(), mima:$('#mima').val(), yzm:$('#yzm').val(), }, function(data){ $("#s6").text(data).css('color', 'red'); if($.trim(data) =='登录成功'){ $(window).attr('location','index.php'); //成功就页面转向 //alert("信息跳转: " + data ); }else{ //alert("信息1: " + data ); return false} }); }else{alert('请填写信息再点击登录!');} });}); </script> </html>