User Registration and Form Validation Using CodeIgniter

Language

By using CodeIgniter framework, you’ll learn how easy it is to create a registration form with validation using the form_validation library that is built-in with CodeIgniter. This example demonstrates how to validate every control in your form. One example is the validation of email address. All you have to do is simply specify this argument: valid_email. CodeIgniter will simply look for that function and validate the email for you. Here’s the example of the form validate in this code sample.
  1. //validate form input
  2. $this->form_validation->set_rules('guest_title', 'Title', 'required|xss_clean');
  3. $this->form_validation->set_rules('first_name', 'First Name', 'required|xss_clean');
  4. $this->form_validation->set_rules('last_name', 'Last Name', 'required|xss_clean');
  5. $this->form_validation->set_rules('birth_date_year', 'Year', 'xss_clean');
  6. $this->form_validation->set_rules('birth_date__nc_month', 'Month', 'xss_clean');
  7. $this->form_validation->set_rules('birth_date__nc_day', 'Day', 'xss_clean');
  8. $this->form_validation->set_rules('company', 'Company', 'xss_clean');
  9. $this->form_validation->set_rules('url', 'Website', 'xss_clean');
  10. $this->form_validation->set_rules('address', 'Address', 'required|xss_clean');
  11. $this->form_validation->set_rules('address_2', 'Address 2', 'xss_clean');
  12. $this->form_validation->set_rules('city', 'City', 'required|xss_clean');
  13. $this->form_validation->set_rules('state', 'State/Province', 'xss_clean');
  14. $this->form_validation->set_rules('country', 'Country', 'required|xss_clean');
  15. $this->form_validation->set_rules('zipcode', 'Zip/Postal code', 'required|xss_clean');
  16. $this->form_validation->set_rules('phone', 'Phone', 'required|xss_clean');
  17. $this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
  18. $this->form_validation->set_rules('username', 'Username', 'required|xss_clean');
  19.  
  20. $this->form_validation->set_rules('password', 'Password', 'required|matches[password_confirm]');
  21. $this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required');

To configure CodeIgniter,please refer to Getting Started With CodeIgniter.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Submitted byAnonymous (not verified)on Wed, 12/05/2012 - 14:34

Really help full, Thanks a lot.
Submitted byAnonymous (not verified)on Sat, 04/06/2013 - 18:53

when i run the code it redirect me to register , why please?

I also have that problem before. You have to see this: http://stackoverflow.com/questions/16389485/codeigniters-form-action-is-not-working-properly
Submitted byespionage (not verified)on Sat, 05/04/2013 - 15:17

this is used in the latest version of codeigniter sir? version 2.1.3?
Submitted byAnonymous (not verified)on Tue, 05/14/2013 - 11:58

dein code hat nur ein grossses loch >>> $config['csrf_protection'] = FALSE; <<
$config['csrf_protection'] = TRUE; <<< sollte es sein ..

your code only has a big hole >>> $config['csrf_protection'] = FALSE; <<
$config['csrf_protection'] = TRUE; <<<it should be .. and I'm also looking for how to do it right

Submitted byAnonymous (not verified)on Mon, 06/17/2013 - 18:28

Hi! Whenever I run the code it redirect me to register. Thanks!
Submitted byNew Level (not verified)on Tue, 07/29/2014 - 17:58

hello, thanks before but i have a question how to make it only has single notification,
so notice display step by step not list

Regards

Submitted byPolid (not verified)on Thu, 02/05/2015 - 13:55

wana have droptsown for all the countries on the world

how to gerata thi sll

Add new comment