zoukankan      html  css  js  c++  java
  • 验证用户名是否可用例题

    1.注册页面

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script src="jquery-1.11.2.min.js" type="text/javascript"></script>/*要引入文件*/
    </head>
    
    <body>
    <input type="text" id="uid" />
    <span id="ts"></span>
    </body>
    <script type="text/javascript">
    $("#uid").blur(function(){
        //取用户名
        var uid=$("#uid").val();
        //调用AJAX
        $.ajax({
                url:"uidchuli.php",
                data:{uid:uid},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                        if(data>0){
                            $("#ts").html("该用户名已存在");
                            $("#ts").css("color","red");
                            }else{
                                    $("#ts").html("该用户名可用");
                                    $("#ts").css("color","green");
                                }
                    }
            });
    });
    </script>
    </html>

    2.处理页面

    <?php
    $uid=$_POST['uid'];
    include("./lei/AAA.class.php");
    $db=new AAA();
    $sql="select count(*) from family where name='{$uid}' ";
     echo $db->StrQuery($sql);
    
    ?>
  • 相关阅读:
    css
    ubuntu 解压zip 文件乱码
    常用 Git 命令清单
    phpstorm git配置
    github ssh秘钥配置
    ubuntu 安装phpunit
    ubuntu 安装php xdebug
    nginx压缩,缓存
    mysql中max_allowed_packet参数的配置方法(避免大数据写入或者更新失败)
    putty登录显示IP
  • 原文地址:https://www.cnblogs.com/zxl89/p/6054413.html
Copyright © 2011-2022 走看看