Welcome Guest, Not a member yet? Register   Sign In
custom form validation
#1

[eluser]andieevans[/eluser]
Hi

I have some code which check for a number of records in a database before allowing the form data to be added...

now I have a check box which once ticked on the form and the user submits, the form data needs to be added to a table, but only if there are less than x records...

using the code below, how do i get the userid into the function?



Code:
if ($this->input->post('mycheckbox'))
  {
   $this->form_validation->set_rules('mycheckbox','My Checkbox','callback_count_records');
  }


Code:
public function count_records($uid=0)
{
  $q = $this->db->query("SELECT * FROM mytable WHERE userid = ".$uid );
  $c = $q->num_rows();
  
  if ($c > 19)
   return false;
  else
   return true;
  
}




Messages In This Thread
custom form validation - by El Forum - 07-11-2012, 09:08 AM
custom form validation - by El Forum - 07-11-2012, 10:01 AM
custom form validation - by El Forum - 07-12-2012, 08:02 AM
custom form validation - by El Forum - 07-12-2012, 09:30 AM
custom form validation - by El Forum - 07-12-2012, 11:16 AM
custom form validation - by El Forum - 07-12-2012, 11:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB