Having problem with form validations... pls help - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Having problem with form validations... pls help (/showthread.php?tid=18076) |
Having problem with form validations... pls help - El Forum - 04-24-2009 [eluser]Ram2810[/eluser] When i am submitting a form am not getting any error msg just page refreshing . Please any one tell what am doing wrong ............. following are the codes used .............if any mistake pls do correct me. This is the controller page where i used the abpout validations <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $config = array( 'customer/enter_details' == array( array( 'field' => 'c_name', 'label' => 'Customer Name', 'rules' => 'trim|required|min_length[5]|max_length[10]|alpha' ), array( 'field' => 'c_o_name', 'label' => 'Customer_Owner_Name', 'rules' => 'trim|required|min_length[5]|max_length[10]|alpha' ), array( 'field' => 'c_place', 'label' => 'Customer Place', 'rules' => 'trim|required|min_length[5]|max_length[10]|alpha' ), array( 'field' => 'c_phone_1', 'label' => 'Phone No-1', 'rules' => 'required|numeric' ), array( 'field' => 'c_phone_2', 'label' => 'Phone No-2', 'rules' => 'required|numeric' ), array( 'field' => 'c_phone_3', 'label' => 'Phone No-3', 'rules' => 'required|numeric' ) ) ); ?> This is my controller page where i call form_validation.php <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class Customer extends Controller { function index() { } function enter_details() { #Validations $this->load->library('form_validation'); #Input and textarea field attributes $data['c_name'] = array('name' => 'c_name', 'id' => 'c_name'); $data['c_o_name'] = array('name' => 'c_o_name', 'id' => 'c_o_name'); $data['c_place'] = array('name' => 'c_place', 'id' => 'c_place'); $data['c_phone_1'] = array('name' => 'c_phone_1', 'id' => 'c_phone_1'); $data['c_phone_2'] = array('name' => 'c_phone_2', 'id' => 'c_phone_2'); $data['c_phone_3'] = array('name' => 'c_phone_3', 'id' => 'c_phone_3'); if ($this->form_validation->run() == FALSE) { $this->load->view('customer_view', $data); } else { $this->load->view('customer_success'); } } } ?> v The view page is as follows <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Customer information entering form</title> <style type="text/css"> body { font: small/1.5em Verdana, Arial, Helvetica, serif; } </style> </head> <body> <h1>Customer information</h1> <p>Enter following Customer information:</p> <?echo $this->form_validation->error_string;?> <?php echo form_open('customer/enter_details'); ?> <p><label for="c_name">Customer Name: </label><?php echo form_input($c_name); ?></p> <p><label for="c_o_name">Customer Owner Name: </label><?php echo form_input($c_o_name); ?></p> <p><label for="c_place">Customer Place: </label><?php echo form_input($c_place);?></p> <p><label for="c_phone_1">Phone No-1: </label><?php echo form_input($c_phone_1);?></p> <p><label for="c_phone_2">Phone No-2: </label><?php echo form_input($c_phone_2);?></p> <p><label for="c_phone_3">Phone No-3: </label><?php echo form_input($c_phone_3);?></p> <?php echo form_submit('submit', 'Submit'); ?> <?php echo form_close(); ?> </body> </html> Thank you in advance Having problem with form validations... pls help - El Forum - 04-24-2009 [eluser]TheFuzzy0ne[/eluser] Try: Code: <?php echo $this->form_validation->error_string; ?> You're server might not support short tags. If you really must use short tags and your server doesn't support them, CodeIgniter can parse them for you at the cost of a little extra overhead. Having problem with form validations... pls help - El Forum - 04-24-2009 [eluser]Ram2810[/eluser] Stil the problem prsists ,can any onr help me here pls thank you Having problem with form validations... pls help - El Forum - 04-24-2009 [eluser]TheFuzzy0ne[/eluser] I'm not sure if this is the problem here, but you don't seem to be calling the parent controller's constructor. You need to add this to your controller class: Code: function Customer() Having problem with form validations... pls help - El Forum - 04-28-2009 [eluser]davido[/eluser] May I suggest you change Code: ‘customer/enter_details’ == array( to... Code: ‘customer/enter_details’ => array( And turn on logging, you might see something like this: DEBUG - 2009-04-28 14:11:18 --> Unable to find validation rules |