tp框架的ajax验证用户姓名的比较

数据库设计随意设计吧 反正就是用户可以存入就可以了!

十年的万载网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都营销网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整万载建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“万载网站设计”,“万载网站推广”以来,每个客户项目都认真落实执行。

正文tp后台方法简化:

 //用户验证
   function checknm($name){
       $info = D('user')->where("user_name ='$name'")->find();
       //dump($info);die;
       $flag = '';
       if($info){
          echo 1;
         
       }else{
          echo 2;
        
       }
   }

后台返回1和2

前端ajax部分 用data接收1和2的状态

当然data的接收 主要看你后台传的是什么格式的数据类型了!这个大家可以百度ajax了!


                    
                        
                                                                                                                                                                                                                                                function checkname(){                                         var name = document.getElementById('User_username').value;                                                                              $.get('/tpTest/index.php/User/checknm',{name:name},function(data){                                             //alert(name);                                          if(data == 1){                                            var nm = document.getElementById('span1');                                            nm.innerHTML='用户名存在';                                            nm.className ="msg2";                                          }                                          if(data == 2){                                          var nm = document.getElementById('span1');                                            nm.innerHTML='用户可以使用';                                            nm.className ="msg";                                                                                    }                                         })                                                                 }                                                                                                                                                                                                 用户名                                                                                                                                                                                                                                                                                                                      
网站标题:tp框架的ajax验证用户姓名的比较
网页地址:http://pwwzsj.com/article/gejgeo.html

其他资讯