• We just launched and are currently in beta. Join us as we build and grow the community.

User Registration and Form Validation Using CodeIgniter

invalidity

IoT Analytics Pro
I Rep
0
0
0
Rep
0
I Vouches
0
0
0
Vouches
0
Posts
62
Likes
20
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
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. $this

    ->

    form_validation

    ->

    set_rules

    (

    'password'

    ,

    'Password'

    ,

    'required|matches[password_confirm]'

    )

    ;
  20. $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.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

442,401

317,942

317,951

Top