Sharing Top Content from the Angular-sphere.

Live username Availability check with AngularJS in CodeIgniter

Live username Availability check with #AngularJS in #CodeIgniter  #PHP #makitweb

  • In the demonstration, I am creating a simple registration form in CodeIgniter where check the entered username with Angular and insert the record if the username is available.
  • Count total records available according to the username in table and return the count.
  • To check entered username is available or not define directive and display warning message using when return .
  • Create two functions – – – checkUsename – Send request where pass the and on successfully callback check value if it is greater than 0 means username is not available and set otherwise set .
  • You can create separate methods in the controller and model for handling or use the same methods but update the code to handle both requests for the username and email element.

Live username availability check validation is user-friendly and notifies the user that username is available or not. If you are already using Angular in your project then you can use $http request. In this tutorial, I show how you can check username availability and insert record using AngularJS in CodeIgniter.

If there is the registration form on the website then you need to make sure that the username or email must be unique.

The user will login with the selected username next time when it comes to the website.

You can either check it after submitting the form or while entering it.

In the demonstration, I am creating a simple registration form in CodeIgniter where check the entered username with Angular and insert the record if the username is available.

table in the demonstration.

CREATE TABLE `users` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `username` varchar(60) NOT NULL, `name` varchar(60) NOT NULL, `email` varchar(80) NOT NULL, `password` varchar(60) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

and define Database connection.

$db[‘default’] = array( ‘dsn’ => ”, ‘hostname’ => ‘localhost’, ‘username’ => ‘root’, // Username ‘password’ => ”, // Password ‘database’ => ‘tutorial’, // Database name ‘dbdriver’ => ‘mysqli’, ‘dbprefix’ => ”, ‘pconnect’ => FALSE, ‘db_debug’ => (ENVIRONMENT !== ‘production’), ‘cache_on’ => FALSE, ‘cachedir’ => ”, ‘char_set’ => ‘utf8’, ‘dbcollat’ => ‘utf8_general_ci’, ‘swap_pre’ => ”, ‘encrypt’ => FALSE, ‘compress’ => FALSE, ‘stricton’ => FALSE, ‘failover’ => array(), ‘save_queries’ => TRUE );

$route[‘default_controller’] = ‘User’;

library.

$autoload[‘libraries’] = array(“database”);

directory.

Create 2 methods –

checkUsername – This method takes a single parameter of string type.

table and return the count.

table.

Live username Availability check with AngularJS in CodeIgniter