首页 > 代码库 > TEST

TEST

<?php$link=mysql_connect(‘localhost‘,‘root‘,‘‘);mysql_select_db(‘log_test‘,$link);mysql_query(‘set names utf8‘);var_dump($_POST);$name = $_POST[‘name‘];$sql="select name from log_table where name=‘".$name."‘";$result=mysql_query($sql);$row = mysql_fetch_array($result);if (!$row) {    echo 0;}else{    echo 1;}
<?phpheader("content-type:text/html;charset=utf8");$link=mysql_connect(‘localhost‘,‘root‘,‘‘);mysql_select_db(‘log_test‘,$link);mysql_query(‘set names utf8‘);// print_r($_POST);$name=$_POST["name"];$passwd=$_POST["passwd"];$email=$_POST["email"];$sql="insert into log_table (name,passwd,email) values (‘".$name."‘,‘".$passwd."‘,‘".$email."‘)";if(mysql_query($sql)){    echo ‘注册成功‘;}else{    echo "注册失败";}
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>注册</title><script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script><script>    $(document).ready(function(){        $("#name").blur(function(){            var name=$(this).val();                $.ajax                ({                     url: "checkname.php",                     type: "post",                    // dataType:‘json‘,                    data:{name:name},                    success: function (result) {                        if(result==1){                                alert("用户名已存在");                                $("#name").val(‘‘);                                return false;                            }                    }                })        });                $("#repasswd").blur(function(){            var passwd=$(#passwd).val();            var repasswd=$(#repasswd).val();            if(passwd != repasswd){                alert("确认密码错误");                return false;            }        });        $("#email").blur(function(){            var email=$("#email").val();            if(!email.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/)){                   alert("格式不正确!请重新输入");                   $("#email").val(‘‘);                   return false;                  }        });        $("#button").click(function(){            var email=$("#email").val();            var passwd=$(#passwd).val();            var name = $("#name").val();            var passwd = $("#passwd").val();            var repasswd =$("#repasswd").val();            if(email && passwd && name && email && repasswd !=‘‘){                $("#myform").submit();            }else{                alert("你还有选项没填");            }                    });        // $("button").click(function(){        //   $("buttom").submit();        // });        // $(‘#sub‘).bind(‘click‘,function(){        //     form1.action="register.action";        //     form1.submit();        //   });     });</script>                                                    </head>                                        <body>    <div style="width: 100%;margin-top: 180px;text-align: center;">        <form action="receive.php" method="post" id="myform">            <p>用 户 名:<input type="text" id="name" name="name"></p>            <p>密  码:<input type="password" id="passwd" name="passwd"></p>            <p>确认密码:<input type="password" id="repasswd" name="repasswd"></p>            <p>邮  箱:<input type="text" id="email" name="email"></p>            <input type="button" value="提交" id="button">        </form>    </div>    </body></html>

 

TEST