codeigniter 3 load form validation code example

Example 1: codeigniter load form_validation

<?php

class Form extends CI_Controller {

        public function index()
        {
                $this->load->helper(array('form', 'url'));

                $this->load->library('form_validation');

                if ($this->form_validation->run() == FALSE)
                {
                        $this->load->view('myform');
                }
                else
                {
                        $this->load->view('formsuccess');
                }
        }
}

Example 2: file form validation codeigniter

if (empty($_FILES['userfile']['name']))
{
    $this->form_validation->set_rules('userfile', 'Image', 'required');
}

Tags:

Php Example