php - form validation not working in CodeIgniter -


i'm not able run form validation in codeigniter. not returning errors or submission database.

when i'm using

$this->form_validation->set_rules('subemail', 'email', 'required|valid_email');

my code gets executed not in below case. why?

controller name form_sub :

class form_sub extends ci_controller {          public function __construct() {         parent::__construct();         $this->load->database();         $this->load->library('form_validation');         #loading model                 $this->load->model('form_model');                 $this->load->helper(array("form",'url'));      }#eof constructor      public function index(){         $this->load->view('form.php');     }//default page     public function subscribe(){             echo "hello1";              $config = array(                     'field' => 'email',                     'label' => 'email id',                     'rules' => 'required|max_length[50]|min_length[5]|valid_email|trim|htmlspecialchars',                     'errors'=>[                         'required' => '* must provide %s',                         'max_length' => '* %s should of maximum 50 characters',                         'min_length' => '* %s should of minimum 5 characters',                         'valid_email' => '* must provide valid %s'                      ]                 )              $this->form_validation->set_rules($config);             echo "hello2";               if($this->form_validation->run() == false){               $this->load->view('form.php');               echo "hello3";               } 

view name form.php :

<div class="row">               <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8">               <?php echo form_open('form_sub/subscribe'); ?>                 <input name="email" id="" type="text" value="<?php echo set_value('email');?>" class="normal" placeholder="email address">                     <?php echo form_error('email'); ?>                    </div>               <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 button"> <!--                <input type="submit" id="subsubmit" name="send" class="button" value="subscribe">-->                   <input type="submit" class="button" value="subscribe">                 <?php echo form_close(); ?>               </div>             </div> 

model name form_model :

class form_model extends ci_model {     public function __construct() {          parent::__construct();      }           public function subscribe_insert($data)                 {             if($this->db->insert('subscribe',$data))                     {                 return true;             }             else             {                 echo "something went wrong in database";             }         }  } 


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -