PHP
  Home arrow PHP arrow Page 3 - 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 - Repopulating a web form with Code Igniter
    ( Page 3 of 4 )

    To be frank, creating the view file responsible for displaying all the errors that might occur when validating the sample web form, and for repopulating its fields when applicable, is a straightforward process that you’ll grasp very quickly.

    However, to clarify how this view is going to work, please examine its corresponding signature, which is shown below:


    <!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>Entering user data</title>

    <head>

    <body>

    <h1>Entering user data</h1>

    <?php echo $this->validation->error_string;?>

    <?php echo form_open('validator');?>

    <p>First Name <input type="text" name="firstname" value="<?php echo $this->validation->firstname;?>" size="50" /></p>

    <p>Last Name <input type="text" name="lastname" value="<?php echo $this->validation->lastname;?>" size="50" /></p>

    <p>Email <input type="text" name="email" value="<?php echo $this->validation->email;?>" size="50" /></p>

    <p><input type="submit" value="Send Data" /></p>

    </form>

    </body>

    </html>


    Definitely, that wasn’t rocket science, was it? As shown before, the above view file is responsible for displaying a simple contact form, which not surprisingly is composed of three text boxes, which come in handy for entering typical data, such as the user’s first and last names, and an email address as well.

    Nevertheless, if you have a closer look at the view file in question, then you’ll see that on top of it, the Code Igniter validation class is used to display all of the  errors that might arise when validating the web form. Other than that, there are a few additional PHP statements interspersed with the structural markup, which are used to repopulate the form’s fields and to generate dynamically the URL for its “action” attribute.

    Now you have learned how to build a simple view file that not only will be capable of displaying on screen all of the error messages that occurred when validating the sample HTML form, but will refill its fields with the data entered previously by a user.

    Therefore, save this file to the Code Igniter /system/application/views/folder as “webform_view.php” and once you’ve done this, please jump forward and read the following section. In that part, I’ll explain how to build the remaining view file, which will be responsible for showing a confirmation message, after the web form has been submitted successfully.



     
     
    >>> 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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek