Please follow the tutorial https://roytuts.com/username-availability-check-using-codeigniter-ajax-and-mysql/