[eluser]Cro_Crx[/eluser]
If you already have a column that is unique and can be used as a primary key then there is no need for another one. Why can't you just use the already existing field, the one in the example above as (employeeID_two).
To stop the database holding two users with the same ID, you should use a callback function when validating the data, something like this:
Code:
$this->form_validation->set_rules('employeeID', 'Employee ID', 'required|callback__id_already_exists');
function _id_already_exists($employee_id)
{
// This should be put into a model but i'm just putting it here for simplicity
$this->db->where('employeeID', $employeeID);
if($this->db->get('tblemployee')->num_rows() > 0)
{
return false;
}
return true;
}
BTW: To access post variables you can use
Code:
$this->input->post('POST_ITEM')
instead of
It returns false if the item doesn't exist where as using $_POST directly doesn't!