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

[eluser]bret[/eluser]
I'm writing a script for a user to verify their email address.

After a user registers on my site, an email is sent to their address with a link to verify:

http://www.example.com/register/verify/12345

where 12345 is their activation code. I'm currently at the point where I want to check this activation code to see if it exists in my users table, and if found, replace "12345" with "activated" in that row.

I was considering UPDATE

Does anyone have any suggestions on the best way to do this? OR if you are willing to share your email verify script (if you have one), that would also be greatly appreciated.

Thanks in advance
#2

[eluser]bret[/eluser]
I think I figured it out.

Code:
$data = array('user_code' => "activated");
    $where = "user_code = ".$this->uri->segment(3);
    $query = $this->db->update('users', $data, $where);

    return $query;


I'm still interested in seeing anyone else's email verify code if anyone is willing to share. Smile
#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...
#4

[eluser]Roy MJ[/eluser]
.




Theme © iAndrew 2016 - Forum software by © MyBB