Reputation: 1011
function form_submit (){
$this->load->library('form_validation');
$this->form_validation->set_rules('cname', 'Company Name', 'required');
$this->form_validation->set_rules('cpname', 'Contact Person Name', 'required');
$this->form_validation->set_rules('add1', 'Address Line 1 ', 'required');
if($this->form_validation->run() == TRUE) {
echo 'sucess';
}
else {
echo validation_errors();
}
}
here is my form
<form id="form_sub" action="controller/form_submit">
<div class="row">
<div class="col-sm-6">
<label>Company Name <span>*</span></label>
<input name="cname" type="text" value="" maxlength="100" />
<div class="clear"></div>
</div>
<div class="col-sm-6">
<label>Contact Person <span>*</span></label>
<input name="cpname" type="text" value="" maxlength="100" />
<div class="clear"></div>
</div>
<div class="col-sm-6">
<label>Address Line 1 <span>*</span></label>
<input name="add1" type="text" value="" maxlength="100" />
<div class="clear"></div>
</div>
<input type="submit" value="submit" />
</div>
</form>
All the time $this->form_validation->run() is returning false . What am i missing here , even if i give correct values and submit the form it gives error
Upvotes: 0
Views: 822
Reputation: 5398
You missed the method
attribute in form tag. It should be
<form id="form_sub" action="<?php echo site_url('controller/form_submit');?>" method="POST">
Upvotes: 2