I am new to code Igniter, I am facing with a little problem while validating form. The problem which i am facing is that the view with error is displayed with the original view. I don't know how to fix it. here is my code
<?php
class Tender extends CI_Controller {
function __construct()
{
parent::__construct();
$this->is_logged_in();
}
function add_nit()
{
$data['title'] = 'Add NIT';
$data['main_content'] = 'tendermanager/add_nit';
$this->load->view('includes/main_template',$data);
if(isset($_POST['name']))
{
$this->form_validation->set_rules('name', 'name', 'required');
$this->form_validation->set_error_delimiters('<p class="alert alert-danger">', '</p>');
if ($this->form_validation->run() == false)
{
$this->load->view('tendermanager/add_nit');
}
else
{
// redirect('tendermanager/tender/add_nit');
}
}
} }
View 1 (dashboard)
<?php $this->load->view('includes/main_header');?>
<div class="container-fluid" style="padding-top:90px;">
<div class="row-fluid">
<? echo $this->load->view('sidebar');?>
</div>
<div class="span9 well" style="background:#fff;">
<div class="page-header">
<h1>add <small></small></h1>
</div>
<?php $this->load->view('tendermanager/add_nit');?>
</div>
View 2 (add_nit)
<?php
echo form_open('tendermanager/tender/add_nit');?>
<div class="form-group">
<label>Office Name</label>
<input type="text" name="name" value="<?php echo set_value('name'); ?>" size="50" />
<?php echo form_error('name'); ?>
<br/>
<input type="submit" name='basicdetails' value="Get NIT Number" class="btn btn-primary"></button>
<?php echo form_close();?>