Learn how to check username availability using php, mysql and ajax. Here is the php script to check if username already exists in mysql database or not.
Read this post on kodingmadesimple.com