Welcome Guest, Not a member yet? Register   Sign In
verify email script - suggestions?
#3

[eluser]Roy MJ[/eluser]
Controller for validating..

Code:
$rand_code = random_string('alnum', 10);
$this->Profile_model->save('Add',$rand_code,'');

//Sending mail and link part :

$to = $this->input->post('email');
                $fromemail = $this->config->item('admin_email');
                $fromname = site_name();
                //$this->email->from($this->config->item('admin_email'), site_name());
                $message = "Hello $name, \n\nThank you for registering with BrightPocket.\n\n\nUsername : $username \n\nPassword : $password \n\n\nPlease click on the link in order to activate your account\n\n";
                  $message .= site_url()."/profile/activate/".$rand_code;
                $subject = "Complete Registration";
                mail($to, $subject, $message, "From: $fromname<$fromemail>" );

function activate($code)
     {
           $code = $this->db->escape_str($code);
           $sql = "SELECT id FROM members WHERE activation_code = '".$code."' LIMIT 1";
           $query = $this->db->query($sql);
           if($query->num_rows() == 1)
           {
                 $sql = "UPDATE members SET active = 1 WHERE activation_code = '".$code."' AND active = 0";
                 $this->db->query($sql);
                 $this->data['alert'] = 'Your account has been successfully verified. Login to access your account';
                 $this->load->view('profile/signin', $this->data);
                 return TRUE;
           }
           return FALSE;
     }

Its working fine for me ..:p... the code will be added to the table when user registers first time and this is checked the second time around when the user clicks the link in his mail for validation...


Messages In This Thread
verify email script - suggestions? - by El Forum - 03-26-2011, 03:05 PM
verify email script - suggestions? - by El Forum - 03-26-2011, 03:37 PM
verify email script - suggestions? - by El Forum - 04-07-2011, 04:48 AM
verify email script - suggestions? - by El Forum - 04-07-2011, 04:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB