[eluser]russ_kern[/eluser]
I have a data entry form with a phone number field. I have broken the field into 3 parts to gather the Area code, first 3 digits and the last 4. I want to treat these as an array. The html for the feilds in my form look like:
Code:
<input id="enter" type="text" name="dphone[]" value="<?php echo set_value('dphone[]'); ?>" size="3"> -
<input id="enter" type="text" name="dphone[]" value="<?php echo set_value('dphone[]'); ?>" size="3"> -
<input id="enter" type="text" name="dphone[]" value="<?php echo set_value('dphone[]'); ?>" size="4">
My form validation looks like:
Code:
$this->form_validation->set_rules('dphone[]', 'Day Phone', 'trim|required|xss_clean|callback_phonecheck');
And the callback looks like:
Code:
function phonecheck($str)
{
$sql = "SELECT * FROM entries WHERE dphone = ?";
$query = $this->db->query($sql, $str);
if ($query->num_rows() > 0)
{
$this->form_validation->set_message('phonecheck', 'Only one entry is allowed per phone number');
return FALSE;
} else {
return TRUE;
}
}
The line of code to insert the Complet phone number into the DB looks like:
Code:
$this->dphone = $this->input->post('dphone[]');
The regular form validations work correctly but on submission to the database it inserts a '0'
The way I want it to insert is: 1112223333
My callback isn't working correctly either, but this is probably due to the record insertion into the database... If I can get the data insertion working correctly I'll tackle that next.
I followed the userguide on this (I think) - I'm hoping someone can point out what I have done wrong. Hopefully this makes sense...
Thanks in advance.
Russ