[eluser]joshsmith[/eluser]
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
Code: 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('[email protected]', '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
Code: 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;
}
}
[eluser]scottwire[/eluser]
The link in the email you are sending out is pointing to /user/confirmation_activation but your function is called account_activation. The echo is correct, but the email message is not.
in the anchor call, change confirmation_activation to account_activation
Code: $this->email->message('Click the link below to activate your account' . anchor('http://localhost/codetwo/index.php/user/account_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');
[eluser]joshsmith[/eluser]
good eye, i corrected that error but i still get the same thing. anything else which doesn't seem right?
[eluser]jblack199[/eluser]
I see you have $this->output->enable_profiler(1); there, but have you actually used it to check the query formats in your function to ensure they are properly formatted to actually run?
[eluser]joshsmith[/eluser]
i plugged it into this function but i got no output, like nothing showed, its like that line of script didnt exist. what did i do wrong?
Code: 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';
}
}
[eluser]jblack199[/eluser]
Try putting it at the beginning of the function.. also take out the 1.. and see if you get any output then...
[eluser]joshsmith[/eluser]
I tried both of your suggestions and still no luck. what do you think happened?
[eluser]CodeIgniteMe[/eluser]
You have too much something when you used the anchor function
Code: $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');
it should just be
Code: $this->email->message('Click the link below to activate your account' . anchor('user/confirmation_activation/' . $activation_code,'Confirmation Register'));
//$this->email->send();
echo 'Click the link below to activate your account' . anchor('user/account_activation/' . $activation_code,'Confirmation Register');
[eluser]joshsmith[/eluser]
wait i just realized i put the wrong directory in the anchor. i have changed that and now it goes to the function account_activation but i get a error on line 57
Line 57
Code: $register_code = $this->url->segment(3);
Code: function account_activation() {
// $this->output->enable_profiler(1);
$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);
if($reg_confirm) {
echo 'You have registered ';
}
else {
echo 'you have failed to register';
}
}
[eluser]scottwire[/eluser]
url should be uri
Code: $register_code = $this->uri->segment(3);
|