• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having problem with form validations... pls help

#1
[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">
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Customer information entering form&lt;/title&gt;
&lt;style type="text/css"&gt;
body {
font: small/1.5em Verdana, Arial, Helvetica, serif;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>Customer information</h1>
<p>Enter following Customer information:</p>
&lt;?echo $this->form_validation->error_string;?&gt;
&lt;?php echo form_open('customer/enter_details'); ?&gt;
<p><label for="c_name">Customer Name: </label>&lt;?php echo form_input($c_name); ?&gt;</p>
<p><label for="c_o_name">Customer Owner Name: </label>&lt;?php echo form_input($c_o_name); ?&gt;</p>
<p><label for="c_place">Customer Place: </label>&lt;?php echo form_input($c_place);?&gt;</p>
<p><label for="c_phone_1">Phone No-1: </label>&lt;?php echo form_input($c_phone_1);?&gt;</p>
<p><label for="c_phone_2">Phone No-2: </label>&lt;?php echo form_input($c_phone_2);?&gt;</p>
<p><label for="c_phone_3">Phone No-3: </label>&lt;?php echo form_input($c_phone_3);?&gt;</p>
&lt;?php echo form_submit('submit', 'Submit'); ?&gt;
&lt;?php echo form_close(); ?&gt;
&lt;/body&gt;
&lt;/html&gt;



Thank you in advance

#2
[eluser]TheFuzzy0ne[/eluser]
Try:

Code:
&lt;?php echo $this->form_validation->error_string; ?&gt;

# instead of

&lt;?echo $this->form_validation->error_string;?&gt;

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.

#3
[eluser]Ram2810[/eluser]
Stil the problem prsists ,can any onr help me here pls

thank you

#4
[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()
{
    parent::Controller();
}

#5
[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 --&gt; Unable to find validation rules


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.