PHP
  Home arrow PHP arrow Page 4 - Performing Strict Validation with the Code Igniter PHP Framework
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Performing Strict Validation with the Code Igniter PHP Framework
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2008-09-10


    Table of Contents:
  • Performing Strict Validation with the Code Igniter PHP Framework
  • Performing strict validation on user-provided data with Code Igniter
  • Repopulating a web form with Code Igniter
  • Completing the form validation application

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Performing Strict Validation with the Code Igniter PHP Framework - Completing the form validation application
    ( Page 4 of 4 )

    In the prior section, I demonstrated how simple it is to check data entered into a sample online form by means of the validation class that comes with Code Igniter. As you saw earlier, it’s perfectly possible to repopulate its fields, too, by adding only a few lines of PHP code.

    Nonetheless, to finish developing this HTML form validation application, it’s necessary to generate yet another view file. This file will be tasked with displaying on the browser a simple confirmation message once the pertinent form has been submitted successfully.

    So, with this in mind, below I included the definition of this brand new file:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>User data submitted successfully!</title>

    </head>

    <body>

    <h1>User data submitted successfully!</h1>

    <p><?php echo anchor('validator','Go and submit the form again');?></p>

    </form>

    </body>

    </html>


    Did you ever think that creating a confirmation view like the one shown above was pretty difficult? Well, fortunately you were wrong! As you can see, the previous view simply will print on screen a typical message indicating the HTML form has been submitted successfully, as you’ve done probably hundreds of times before.

    In addition, it’s worthwhile to notice how the “url” helper function provided by Code Igniter is utilized in this specific case, to include a link that points back to the controller. Of course, this could have been done manually, but I left this task to be accomplished by this helper.

    Now that you have grasped how the previous view file does its business, save it to the Code Igniter /system/application/views/ folder as “success_view.php” and finally type the following URL into your browser’s address field to test this sample web application:


    http://localhost/codeigniter/index.php/validator/


    Here you have it. At this moment, you’re armed with the required background to start developing your own data checking applications with Code Igniter. Try setting other rules for the validation class, and see what happens in each case.

    Final thoughts

    In this fifth chapter of the series, I explained how to use the validation class that comes bundled with Code Igniter to validate more strictly the data entered into a sample web form. As you saw before, thanks to the functionality provided by this class, the whole process was fairly simple to follow.

    In the next part, I’ll show you how to work with Code Igniter’s active record class. In this way you can learn how to select, insert, update and delete database rows without having to get your hands dirty writing SQL statements.

    Don’t miss the next article!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek