i’m at my final step in processing my registration form. I’m at the part where a e-mail is sent and the only way to activate the account is to click on the link. Once clicked i would run a function where it looks for a scrambled code at the end of the url and match it with the one in the database. Once confirmed i would set my activated field to 1 (default as 0). I tried something which makes logical sense to me but it doesn’t seem to change my activated field into 1. any ideas? i dont get any error. key function to look into are
function account_activation—>controller and function confirm_registration—> model
Controller
function register(){
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|xss_clean|callback_dbcheck');
$this->form_validation->set_rules('name', 'Name', 'required|min_length[3]|max_length[20]|xss_clean');
$this->form_validation->set_rules('email', 'E-mail', 'required|min_length[3]|max_length[20]|xss_clean|valid_email');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[3]|max_length[20]|xss_clean');
$this->form_validation->set_rules('password_conf', 'Re-type Password', 'required|min_length[3]|max_length[20]|xss_clean|matches[password]');
if ($this->form_validation->run() == FALSE) {
$this->load->view('viewregister');
}
else {
$username = $this->input->post('username');
$name = $this->input->post ('name');
$email = $this->input->post ('email');
$password = $this->input->post ('password');
$activation_code = $this->random_string(10);
$this->Usermodel->register_user($username,$name, $email, $password, $activation_code);
// send e-mail verification
$this->load->library('email');
$this->email->from('bingo@gmail.com', 'al');
$this->email->to($email);
$this->email->subject('Registration Confirmation');
$this->email->message('Click the link below to activate your account' . anchor('http://localhost/codetwo/index.php/user/confirmation_activation/' . $activation_code,'Confirmation Register'));
//$this->email->send();
echo 'Click the link below to activate your account' . anchor('http://localhost/codetwo/index.php/user/account_activation/' . $activation_code,'Confirmation Register');
// echo " you have been registered $username";
}
}
function account_activation() {
$register_code = $this->url->segment(3);
if ($register_code == '') {
echo 'errpr no registration code in URL';
exit();
}
$reg_confirm = $this->usermodel->confirm_registration($register_code);
$this->output->enable_profiler(1);
if($reg_confirm) {
echo 'You have registered into our syster';
}
else {
echo 'you have failed to register';
}
}
Model
function confirm_registration ($register_code) {
$val_code = "SELECT id from tbregister where activationcode = ?";
$result = $this->db->query($val_code, $register_code);
if ($result->num_rows() == 1) {
$update_activated = "UPDATE `tbregister` SET activated = 1 WHERE activationcode = ?";
$this->db->query($update_activated, $register_code);
return TRUE;
}
else {
return FALSE;
}
}
