A common feature of most new user registration forms is a message telling you whether your chosen username or e-mail is already taken. The check is done through an AJAX request. Using the jQuery Validation plugin, the remote option can be used to request a URL that returns JSON data. Using Codeigniter, this URL is a new function in the controller used for registration. In this example, the register_email_exists() function returns true or false, after checking the entered form value against the database.
The PHP – For your Controller
Change the email_exists function to apply to your database. In this example, I have these functions in a controller called Registration, so the remote URL used in the jQuery is /registration/register_email_exists. Change that URL as necessary for your Codeigniter setup. I found that the json_encode function was necessary for the jQuery to receive the correct value.
The HTML – For your Form
Just make sure that the IDs match up with the validation options:
<input type="text" name="email1" id="email" /> <input type="text" name="email2" id="email2" />
This uses the bassistance.de jQuery Validation Plugin.