08.10.2017 Views

codeigniter_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12. Form Validation<br />

CodeIgniter<br />

Validation is an important process while building web application. It ensures that the<br />

data that we are getting is proper and valid to store or process. CodeIgniter has made<br />

this task very easy. Let us understand this process with a simple example.<br />

Example<br />

Create a view file myform.php and save the below code it in<br />

application/views/myform.php. This page will display form where user can submit<br />

his name and we will validate this page to ensure that it should not be empty while<br />

submitting.<br />

<br />

<br />

My Form<br />

<br />

<br />

<br />

<br />

<br />

Name<br />

<br />

<br />

<br />

<br />

<br />

Create a view file formsuccess.php and save it in<br />

application/views/formsuccess.php. This page will be displayed if the form is<br />

validated successfully.<br />

<br />

<br />

49

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!