[eluser]j4zzyh4ck3r[/eluser]
[quote author="talwinder" date="1302506073"]---------- HERE IS THE CODE OF MY VIEW FILE---------------
<section id="content">
<?php
echo heading('Contact Me', 1);
echo form_open('site/contact', 'id="contact"');
echo form_fieldset();
$nameLabel = array('id' => 'nameLabel', 'for' => 'name');
echo form_label('Name','', $nameLabel);
$nameInput = array('id' => 'name', 'name' => 'name');
echo form_input($nameInput);
echo form_error('name');
$subLabel = array('id' => 'subLabel', 'for' => 'subject');
echo form_label('Subject','', $subLabel);
$subjectInput = array('id' => 'subject', 'name' => 'subject');
echo form_input($subjectInput);
echo form_error('subject');
$telLabel = array('id' => 'telLabel', 'for' => 'tel');
echo form_label('Phone','', $telLabel);
echo form_error('tel');
$telInput = array('id' => 'tel', 'name' => 'tel', 'type' => 'tel');
echo form_input($telInput);
$emailLabel = array('id' => 'emailLabel', 'for' => 'email');
echo form_label('Email','', $emailLabel);
$emailInput = array('id' => 'email', 'name' => 'email', 'type' => 'email');
echo form_input($emailInput);
echo form_error('email');
$messageLabel = array('id' => 'messageLabel', 'for' => 'message');
echo form_label('Message','', $messageLabel);
echo form_textarea('message', '', 'id="message"', 'name="message"');
$submit = array('id' => 'submit', 'name' => 'submit', 'value' => ' ', 'type' => 'submit');
echo form_input($submit);
echo form_fieldset_close();
echo form_close();
?>
</section><!--end of content-->
--------------HERE IS THE CODE OF MY CONTROLLER FUNCTION-----------
function contact(){
$data['mainContent'] = 'contact';
$this->load->view('includes/template', $data);
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'trim|required');
$this->form_validation->set_rules('subject', 'Subject', 'trim|required');
$this->form_validation->set_rules('tel', 'Phone', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
if($this->form_validation->run() == FALSE){
}else{
$this->siteModel->addEnquiry();
}[/quote]
Code:
if($this->form_validation->run() == FALSE){
// put your form view here
}else{
$this->siteModel->addEnquiry();
}
You forget to load your view to validate all fields, try to load your form view there...