Welcome Guest, Not a member yet? Register   Sign In
Form and form validation - Can't get it to work
#10

[eluser]cartalot[/eluser]
ok here you call the model in the controller
Code:
$this->user_model->registeruser();

and here is the code in the model
Code:
function registeruser($REGusername, $REGemail, $REGpassword)

so first -- you need to take the values from the form, and pass them to registeruser. theres different ways to do this but take a look at the tutorial in the user guide for some first examples.

and then in the model, for registeruser - put in an error check, and for example return the id if true, and return false if the record did not insert
in model, in registeruser()
Code:
// if record inserted, kick back the ID, else false
if ( $this->db->affected_rows() == '1' )
{
$theid = $this->db->insert_id();
return $theid;
}
else {return FALSE;}

in controller
Code:
// IF registeruser did not create record
if ( ! $id = $this->user_model->registeruser($a,$b,$c) ) {
   $data['site_title'] = 'Register';
       $data['content'] = 'user/register';
    $this->load->view('templates/default', $data);
}
// else you can set $id in a session or whatever needs to happen next
else
{
// success
}


Messages In This Thread
Form and form validation - Can't get it to work - by El Forum - 07-01-2012, 01:09 PM
Form and form validation - Can't get it to work - by El Forum - 07-01-2012, 05:00 PM
Form and form validation - Can't get it to work - by El Forum - 07-01-2012, 05:01 PM
Form and form validation - Can't get it to work - by El Forum - 07-03-2012, 12:45 AM
Form and form validation - Can't get it to work - by El Forum - 07-03-2012, 03:18 AM
Form and form validation - Can't get it to work - by El Forum - 07-03-2012, 05:19 AM
Form and form validation - Can't get it to work - by El Forum - 07-03-2012, 10:41 AM
Form and form validation - Can't get it to work - by El Forum - 07-03-2012, 11:40 AM
Form and form validation - Can't get it to work - by El Forum - 07-03-2012, 04:21 PM
Form and form validation - Can't get it to work - by El Forum - 07-04-2012, 02:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB