Home arrow PHP arrow Page 4 - Validating Web Forms with the Code Igniter PHP Framework

Building a confirmation view file - PHP

If you're a web developer, you've probably written any number of scripts designed to validate the input entered into a web form. More than likely, then, you'd like something that will make that job easier. Enter the Code Igniter PHP framework. In this fourth part of a nine-part series on this framework, you'll learn how to use it to do basic validation on a web form.

  1. Validating Web Forms with the Code Igniter PHP Framework
  2. Validating user-supplied data using the MVC pattern
  3. Displaying error messages when validating an online form
  4. Building a confirmation view file
By: Alejandro Gervasio
Rating: starstarstarstarstar / 18
September 03, 2008

print this article



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


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

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



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

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




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:


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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: