[eluser]Unknown[/eluser]
Hi,
I had some question about validation.
URL: /ItemDetail/5
ItemDetail is the Controller Name
5 is the Item ID
at this page, visitor can post a price and submit to the website, so I need to do a validation for the Price field.
Code:
<?=form_open('ItemDetail/validatebid'); ?>
<?=form_hidden('Jid',$this->uri->segment(3))?>
<center><?=form_error('price')?></center><br>
<center>price<input name="price" type="text" value="<?=set_value('price')?>"><br>
<?=form_button(array('name' => 'submit', 'type' => 'submit', 'class' => 'btn_post'))?></center>
</form>
In this form, I create a function name ItemDetail/validatebid for the validate:
Code:
$this->form_validation->set_rules('price', 'price', 'trim|numeric|max_length[6]');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('itemdetail', $data);
}
else
{
$this->load->model('data_model');
$this->data_model->insert_bid();
redirect('itemdetail/'.$this->uri->segment(2));
}
problem occur: when user input pass the submit button, it will go to ItemDetail/validatebid for validation, at that time, the Item ID didn't contain the Item ID in segment(2), I can't display proper Item Information. How can I fix this problem?