mardi 23 février 2016

How to compare text field with mysql database field while typing on a php form?

im facing a problem in my project. Here is simpler explanation in code parts. Let i have a mysql database named db having table named tb containing entries as follows:

table tb {

username: david, ford, sara, andrew
level: 22, 1, 3, 12

}

I have a form in index.php like:

<?php

..... let the submitted data is stored in these variables:
$username, $level;
?>

<form method="post">
Username: <input type="text" name="username">
Level: <input type="text" name="level">
<input type="submit" name="submit" value="Register">
</form>

I want that when user is typing in the username field. It automatically check in the database while on the time of typing if the currently being typed string matches with any of the equavilent mysql database field. if true, then it should warn and disable the submit button. if false then it should not warn and submit button enabled as well. For example: if user types david in username, then it should disable the register button because david name is already existed in mysql database.




Aucun commentaire:

Enregistrer un commentaire