Welcome Guest, Not a member yet? Register   Sign In
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


Messages In This Thread
Having problem with form validations... pls help - by El Forum - 04-24-2009, 12:04 PM
Having problem with form validations... pls help - by El Forum - 04-24-2009, 12:12 PM
Having problem with form validations... pls help - by El Forum - 04-24-2009, 06:08 PM
Having problem with form validations... pls help - by El Forum - 04-24-2009, 06:22 PM
Having problem with form validations... pls help - by El Forum - 04-28-2009, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB