In this tutorial, We will learn how to implement username live check availability feature using PHP, jQuery and MySQL.We will send AJAX request to the server-side script(PHP) and get a response from the ajax request as a JSON object.
We will show a success/error message if the user name is available/exists or validation type error. It’s very useful when you are checking username availability on live form from the database.
This functionality is important when you are providing username availability on live enter of username.
Step 1: Create a table to store the username into the database.
CREATE TABLE `users` ( `id` int(10) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO `users` ( `id` , `username` , `email` ) VALUES (NULL , 'phpflow', 'phpflow@phpflow.com'), (NULL , 'parvez', 'parvez@phpflow.com')
Step 2: Created a database connection file connection.php
, to connect MySQL database to PHP.
<?php /* Database connection start */$servername = "localhost"; $username = "root"; $password = ""; $dbname = "test"; $conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error()); /* check connection */if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); }?>
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More
View Comments
Hi,
This code looks good but where is the database connection?
Thanks,
Ben
Hi Ben,
I had assumed , User has database connection layer.
Thank That's what i want to learn
Download Link Not Working
fixed url issue