Codeigniter : Basic Form Validation
Example code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title> form_error </title> </head> <body> <h3> Test form_error </h3> <form action="" method="post" accept-charset="utf-8"> <br /> <?php echo form_error('fname');?> fname : <input type="text" name="fname" value="<?php echo set_value('fname');?>" /> <br /> <?php echo form_error('lname');?> <br/> lname : <input type="text" name="lname" value="<?php echo set_value('lname');?>" /> <br/> <input type="submit" name="mysubmit" value="submit" /> </form> </body> </html> |
Result
if don’t input anything in form echo ERROR : pls input xxxx