Through Ajax to the database to verify the existence of this user:
PHP Code:
1<?PHP2 if(isset($_get[' User '])){3 $user=$_get[' User '];4 include("util.php");5 $sql= "SELECT count (*) from ' username ' where sname = '$user‘";6 $result=mysql_query($sql);7 $row=Mysql_fetch_row($result);9 if($row[0]){Ten Echo"The user has already been registered!" "; One}Else { A Echo"The user has not been used and can register!" "; - } - } the -?>
JS Code:
1 varxmlHttp;2 functiongetxmlhttp () {3 if(window. ActiveXObject) {4XmlHttp =NewActiveXObject ("MICROSOFT. XMLHTTP ");5}Else if(window. XMLHttpRequest) {6XmlHttp =NewXMLHttpRequest ();7 }8 }9 functionsendparam (URL) {Ten getxmlhttp (); OneXmlhttp.open ("GET", "register.php?user=" +url,true); AXmlhttp.onreadystatechange =Gettxt; -Xmlhttp.send (NULL); - } the functionGettxt () { - if(Xmlhttp.readystate = = 4){ - if(Xmlhttp.status = = 200){ - varSP = document.getElementById ("Tishi"); +sp.innerhtml =Xmlhttp.responsetext; - } + } A}
HTML code:
1 <formMethod= "POST"Action= "register.php">2User:<inputclass= "INP"onblur= "Sendparam (this.value)"type= "text"name= "User">3 <spanstyle= "color: #ff0000; font-size:16px"ID= "Tishi"></span> <BR> <BR>4Password:<inputclass= "INP"type= "Password"name= "pwd"><span></span>5 <inputID= "CE"type= "Submit"name= "Submit"value= "Register">6 </form>