User Registration and Form Validation Using CodeIgniter
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.
//validate form input $this->form_validation->set_rules('guest_title', 'Title', 'required|xss_clean'); $this->form_validation->set_rules('first_name', 'First Name', 'required|xss_clean'); $this->form_validation->set_rules('last_name', 'Last Name', 'required|xss_clean'); $this->form_validation->set_rules('birth_date_year', 'Year', 'xss_clean'); $this->form_validation->set_rules('birth_date__nc_month', 'Month', 'xss_clean'); $this->form_validation->set_rules('birth_date__nc_day', 'Day', 'xss_clean'); $this->form_validation->set_rules('company', 'Company', 'xss_clean'); $this->form_validation->set_rules('url', 'Website', 'xss_clean'); $this->form_validation->set_rules('address', 'Address', 'required|xss_clean'); $this->form_validation->set_rules('address_2', 'Address 2', 'xss_clean'); $this->form_validation->set_rules('city', 'City', 'required|xss_clean'); $this->form_validation->set_rules('state', 'State/Province', 'xss_clean'); $this->form_validation->set_rules('country', 'Country', 'required|xss_clean'); $this->form_validation->set_rules('zipcode', 'Zip/Postal code', 'required|xss_clean'); $this->form_validation->set_rules('phone', 'Phone', 'required|xss_clean'); $this->form_validation->set_rules('email', 'Email Address', 'required|valid_email'); $this->form_validation->set_rules('username', 'Username', 'required|xss_clean'); $this->form_validation->set_rules('password', 'Password', 'required|matches[password_confirm]'); $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
Polid (not verified)
Thu, 02/05/2015 - 13:55
Permalink
thanks ...
wana have droptsown for all the countries on the world
how to gerata thi sll
New Level (not verified)
Tue, 07/29/2014 - 17:58
Permalink
how to create single notification
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
sagar.ch
Thu, 06/12/2014 - 22:04
Permalink
Thanks..
Simple and really helpful
nitheee (not verified)
Thu, 01/16/2014 - 13:46
Permalink
how to Validate Photo field
how to Validate Photo field
gajanan004
Mon, 08/19/2013 - 19:41
Permalink
this is nice
nice code
gajanan
Anonymous (not verified)
Mon, 06/17/2013 - 18:28
Permalink
Redirect to register
Hi!
Whenever I run the code it redirect me to register.
Thanks!
Anonymous (not verified)
Tue, 05/14/2013 - 11:58
Permalink
CodeIgniter
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
espionage (not verified)
Sat, 05/04/2013 - 15:17
Permalink
codeigniter.
this is used in the latest version of codeigniter sir? version 2.1.3?
Anonymous (not verified)
Sat, 04/06/2013 - 18:53
Permalink
when i run the code it
when i run the code it redirect me to register , why please?
mainframe639
Tue, 05/07/2013 - 23:08
Permalink
Being redirected
I also have that problem before. You have to see this:
http://stackoverflow.com/questions/16389485/codeigniters-form-action-is-...
The problem with troubleshooting is that trouble shoots back.
Anonymous (not verified)
Wed, 12/05/2012 - 14:34
Permalink
Thanks
Really help full, Thanks a lot.
Add new comment