Web coding support
  • Home
  • PHP
  • Phonegap
  • Angular Js
  • Node Js
  • Previous year questions
  • B.Tech Questions
  • RTU

Form validation in codeigniter

  • By admin
  • May-29-2016
  • Codeigniter, PHP
  • 0 Comments.

This post will show validate a form in codeigniter.

ci-validations

Its necessary to validate your form to prevent user to upload any unwanted data.

full validations description of codeIgniter create a controller and load the form validation library and helper form and url.

$this->load->helper(array("form","url"));
$this->load->library('form_validation');

and load your view.

In view

create a html form

<form class="form-basic" method="post">
<input type="text" name="name">
<input type="text" name="email">
</form>

and set rules for validate your form in controller

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

Run validations rule by

if ($this->form_validation->run() == FALSE){
        $this->pageData["from_status"] = "Form successfully validated";
    }

To show the errors, there are a default function by codeigniter validation_errors() . Call this function in your view file.

 

View Live Demo      Download

Source : codeigniter

Related Posts

  • Magic function library for Codeigniter like CakePHPMagic function library for Codeigniter like CakePHP
  • Hide show HTML element by javascriptHide show HTML element by javascript
  • Login with facebook in core phpLogin with facebook in core php
  • How to create pagination in PHP and MySQLHow to create pagination in PHP and MySQL
  • What is a difference between a method and a function?What is a difference between a method and a function?
  • How works ng-hide and ng-show in angular jsHow works ng-hide and ng-show in angular js

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)

Related

FacebookTwitterGoogle+Google GmailPrintPinterestFacebook MessengerWordPressShare

Comments

Leave a Reply Cancel reply

← Previous Post Next Post →

Categories

  • Angular Js
  • Array
  • Codeigniter
  • facebook
  • Javascript
  • jquery
  • MySQL
  • oops
  • Pagination
  • Phonegap
  • PHP

Recent Posts

  • Fetch random results form MySQL
  • HTML DOM Manipulation using JavaScript
  • Magic function library for Codeigniter like CakePHP
  • What is the difference between an interface and abstract class
  • How to reset an array keys in php

Tags

Abstract Class angularjs array codeigniter facebook facebook login facebook sdk form validations function hide html Interface javascript jquery magic functions method mysql ng-hide ng-show nghide ngshow oops pagiation php recursion reference show static static functions

Subscribe us

Name
Email *
About This Site

We provide the simplest tutorials for web development.

Pages
  • Home
  • B.Tech Questions
  • Previous year questions
  • RTU
Categories
  • Angular Js
  • Array
  • Codeigniter
  • facebook
  • Javascript
  • jquery
  • MySQL
  • oops
  • Pagination
  • Phonegap
  • PHP
Search
  • facebook
  • twitter

Powered by Minmarks.com  |  A Coding blog by By Jitendra.

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.