Articles → PHP CODEIGNITER → Validation_Errors And Form_Error In Codeigniter

Validation_Errors And Form_Error In Codeigniter






Purpose


  1. "validation_errors" display the summary of all the error messages.
  2. "form_error" displays error messages at field level.

Example




$this->load->helper('form'); 
$this->load->library('form_validation'); 
$this->form_validation->set rules('username', 'Username', 'required'); 
$this->form_validation->set rules('name', 'Name', 'required'); 
$this->form_validation->run();
$this->load->view('users');




<?php 
echo validation_errors(); 
echo form_open(); 
echo form_input('username', "); 
echo form_error('username',''); 
echo form_input('name', ''); 
echo form_submit('mysubmit', 'Click Me'); 
echo form close();?> 





Output




Picture showing the web page when loaded for first time
Click to Enlarge



Picture showing the output of form_error and validation_errors in codeigniter
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, August 6, 2020

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250