比如我写个注册页面  让用户填写注册信息用于登陆网站 
我应该如何 在用户注册的时候 判断用户是否存在(存在显示提示信息,不存在添加信息)
是在数据库中 字段加上唯一索引约束
还是在业务逻辑层判断  如何实现
新手 求教高手了们了。。!!!!!!!

解决方案 »

  1.   

    用Ajax技术实时跟踪输入字符串
    去数据库中判断或者在输入用户名控件焦点离开的时候判断
    Ajax更新后面的图片
      

  2.   

    用ICallbackEventHander接口,到百度上查查用法,很简单的,相信它一定能解决你的问题。
      

  3.   

    ajax异步获取数据,查询用户数据 
    <script type="text/javascript"> 
        var xmlHttp; 
        function createXMLHttpRequest() 
        { 
            if(window.ActiveXObject) 
            { 
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
            } 
            else if(window.XMLHttpRequest) 
            { 
                xmlHttp = new XMLHttpRequest(); 
            } 
        } 
        function CheckUserName() 
        { 
          var us=document.getElementById("txtname").value; 
          if(us!="") 
          { 
            createXMLHttpRequest(); 
            var url= "RegistValidate.ashx?username="+escape(document.getElementById("txtname").value); 
            xmlHttp.open("GET",url,true); 
            xmlHttp.onreadystatechange=ShowResult; 
            xmlHttp.send(null); 
            } 
        } 
        function ShowResult() 
        { 
            if(xmlHttp.readyState==4) 
            { 
                if(xmlHttp.status==200) 
                { 
                    var s; 
                    s=xmlHttp.responseText; 
                      alert(s); 
                } 
            } 
        } 
    </script>
      

  4.   

    用Ajax异步获取数据,同意五楼的