PHP
  Home arrow PHP arrow Page 4 - Validating Web Forms 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? 
PHP

Validating Web Forms with the Code Igniter PHP Framework
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 10
    2008-09-03


    Table of Contents:
  • Validating Web Forms with the Code Igniter PHP Framework
  • Validating user-supplied data using the MVC pattern
  • Displaying error messages when validating an online form
  • Building a confirmation view file

  • 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


    Validating Web Forms with the Code Igniter PHP Framework - Building a confirmation view file
    ( Page 4 of 4 )

    Building a successful web page that shows a confirmation message to the user when the previous contact web form has been submitted correctly is an extremely simple process. You'll surely grasp it in a snap.

    Below I listed the complete signature for this successful view, so you can see clearly how it works. Here it is:

    <!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>

    That was really simple to code and read, wasn’t it? In this particular case, the above view file will display a typical confirmation message once the pertaining web form has been submitted correctly. Of course, the only detail to stress here is the use of the URL helper function loaded previously by the corresponding controller, which dynamically generates an anchor tag that points to the controller’s location, in case a user wants to submit the online form again.

    Finally, save this new view file to the Code Igniter /system/application/views/ folder, as you did with in the example developed in the previous section, and test the application by typing into your browser’s address field the following URL:

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

    You’ll be amazed at how sweetly the previous example works!

    At this point I explained how to build a basic web application that uses the validation class bundled with Code Igniter to check whether or not the fields of a sample web form have been filled. Indeed, you shouldn’t have major problems understanding how this application works, but naturally you can fill some gaps on this topic by examining all of the code samples included in this tutorial.

    Final thoughts

    In this fourth episode of the series, you hopefully learned how to employ the validation class that comes included with Code Igniter to perform a basic validation on a simple online contact form.

    In the forthcoming article, I’m going to show you how to perform strict validation on the data entered into a sample web form. So, now that you’ve been warned of the topics that will be discussed in the next tutorial, you don’t have any excuses to miss it!



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

       

    PHP ARTICLES

    - 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
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT