So I am making a form for people to register but its not working, and for some reason my debugger in netbeans is not working so I cannot check properly.
This is the html form
<?php
if(validation_errors() != false)
{
echo '<div class="form-group alert alert-danger alert-box has-error">';
echo'<ul>';
echo validation_errors('<li class="control-label">', '</li>');
echo'</ul>';
echo '</div>';
}
/* form-horizontal */
echo form_open('main/insertInformation');
?>
<div class="form-group">
<input type="text" name="name" class="form-control input-lg" placeholder="Name">
</div>
<div class="form-group">
<input type="email" name="email" class="form-control input-lg" placeholder="Email">
</div>
<div class="form-group">
<input type="text" name="phone" class="form-control input-lg" placeholder="Phone">
</div>
<div class="form-group">
<input type="password" name="password" class="form-control input-lg" placeholder="Password">
</div>
<div class="form-group">
<input type="password" name="password_confirm" class="form-control input-lg" placeholder="Confirm Password">
</div>
<div class="form-group">
<button type='submit' class="btn btn-primary btn-lg btn-block">Sign In</button>
</div>
</div>
Then I try to get all this information to my controller like this
public function insertInformation(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('phone', 'Phone', 'required');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[4]|max_length[32]');
$this->form_validation->set_rules('password_confirm', 'Password Confirm', 'required|matches[password]');
if ($this->form_validation->run() == FALSE){
$this->load->view('header_view');
$this->load->view('login_view');
$this->load->view('footer_view');
}else{
$data = array(
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'phone' => $this->input->post('phone'),
'password' => $this->input->post('password')
);
$this->db->trans_begin();
$this->load->model('main_page');
$this->main_page->storeRegisterInfo($data);
$message['account_created'] = 'Your account has been created';
$this->load->view('admin_view', $message);
}
}
And here is the model ,
public function storeRegisterInfo($data){
$insert = $this->db->insert('new_users',$data);
return $insert;
}
and my database looks like this
I am pretty new to codeigniter so I am pretty sure there is alot of errors here, so please do help me out and please do explain me in steps for a better understanding. Thanks!