Live Email Availability Checking using PHP, jQuery and Ajax

Often in registration form we need a a feature to check the live availability of user. Obviously it is worth that after submitting all the details to tell the user that user already registered. It's better approach to tell the user while filling the form.

In this article, we will see a live check availability of email id by using AJAX, jQuery, and MySQL.
You will require to enter the email id and you will be able to check weather the email id already exist or not while typing the email id.

Here is the HTML and jQuery part.


Here on key up we are sending the AJAX request with data email_id to check-availability.php and we will get response from server side in AJAX success callback.


We are returning the 'status' from server side like if email id not exist in 'users' table then 'status' will be true else 'status' will be false.

Based on status I'll be changing the class attribute in span tag. I also return message from the server based on email id availability and set the message in span tag.

Now to to check the email id in table we will need a database connection so here is the MySQL connection with PHP.


Now here is the code for checking the email id availability. I'm considering the table name is 'users' and column name id 'email'.


Here I'm using prepared statement for executing my MySQL query and check the rows count against the email id.

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *