How to Create Username Availability Check using PHP

In this article, we will tackle about Username Availability Check using PHP. This example is common to all of us, and it is popular in the websites. Like “Facebook”, “Gmail”, and etc. If you are creating your user account, after you input the username in the TextBox the script will check if it is an available username or not. NOTE: These list of username is not available in this source code example: "rolyn02", "mark111", and "billGates". Because these list is on already in the database. Username Availability Check Form This form includes textbox field where the user types their username.
  1. <div id="frmCheckUsername">
  2. <b style="font-size:large; color:blue;">Check Username:</b>
  3.         <input name="username" type="text" id="username" class="demoInputBox" onBlur="checkAvailability()" autofocus="autofocus" />
  4. <br />
  5. <br />
  6.         <span id="user-availability-status"></span>    
  7. </div>
  8. <p>
  9.         <img src="LoaderIcon.gif" id="loaderIcon" style="display:none" />
  10. </p>
jQuery Script This is the script for requesting the username availability.
  1. <script>
  2. function checkAvailability() {
  3.         $("#loaderIcon").show();
  4.         jQuery.ajax({
  5.         url: "check_availability.php",
  6.         data:'username='+$("#username").val(),
  7.         type: "POST",
  8.         success:function(data){
  9.                 $("#user-availability-status").html(data);
  10.                 $("#loaderIcon").hide();
  11.         },
  12.         error:function (){}
  13.         });
  14. }
  15. </script>
And, this is the output. Username Not Available Result Username Available Result
If you are interested in programming, we have an example of programs that may help you even just in small ways. Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment