Suppose I have a application form which contain lot of boxes like email,username,age etc...I have connected this application form to database(mysql) through action="register.php" in application form...
NOw i want that in database,username and email id should be unique.Means no two users cant have same username or email id..
What I know to do This....
When you created tables in mysql then make these fields (username,email) unique(by primary key).Butif i submit the form with same username already in database then error msj will be showed on the next page开发者_JAVA百科 something like this.username is priamry.....whatever..
Problem in this...
The error msj should be displayed on the onblur event of that textbox(username textbox and email textbox)..
How i can do this.Please explain with example For your ease i am giving code for application form...something lik ethis
applicationform.php
form name="form" action="register.php" method="GET" >
<tr>
<td>Username</td>
<td><input type="text" id="username" size="30" maxlength="35" value=""></td>
<td><div id="p1"></div></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" id="email" size="30" maxlength="30" value=""></td>
</tr>
<tr>
<td align="center" colspan="100"> <input type="submit" name="submit" value="Submit">
</td>
</tr>
I think you have to make an Ajax request when the blur
event happens and check at the server side whether the the username exists or not.
This AutoCompleter tutorial should give you the right idea how to do this.
精彩评论