Welcome Guest, Not a member yet? Register   Sign In
User confirmation link email issue
#1

[eluser]Xeroxeen[/eluser]
Hi i'm developing a web system which users can register.When user registers the confirmation link sends to his/her email address.Then user should click the link to confirm his registration.I'm using google smtp to send the email.It's working properly.The problem is when i click the link it's not marks the user as activated.This is my model and controller.

Index Controller

Code:
$email=$_POST['email'];
      
      $this->load->library('email',$config);
      $this->email->set_newline("\r\n");
      $this->email->from('myemail', 'Email Name');
      
      
      $this->email->to($email);
      $this->email->subject('Email subject');
      
      
      $this->email->message('Click the link below to activate your account' . anchor('http://localhost/mySite/index.php/Index/account_activation'.$activationCode,'Confirmation Register'));
                        
      
      if($this->email->send())
          {
        echo 'OK';
       }
      
      else
       {
        show_error($this->email->print_debugger());
       }

Model

Code:
function confirm_registration($register_code){

   $val_code = "SELECT email FROM `users` WHERE hash='?'";
   $result = $this->db->query($val_code, $register_code);
  
   if ($result->num_rows() == 1) {
  
    $update_activated = "UPDATE `users` SET is_activated = 1 WHERE hash = ?";
    
  
    $this->db->query($update_activated, $register_code);
  
    return TRUE;
   }
   else {
    return FALSE;
   }
}

Why is not working?I checked it manually by running the SQL query.Then it works.Please help!
#2

[eluser]Unknown[/eluser]
Use $_GET or $_POST access your function()

Code:
$this->email->message('Click the link below to activate your account' . anchor('http://localhost/mySite/index.php/Index/account_activation?id='.$activationCode.'Confirmation Register'));
#3

[eluser]Pert[/eluser]
The link should probably be

anchor('http://localhost/mySite/index.php/Index/account_activation<b>/</b>'.$activationCode,'Confirmation Register')

index.php/Index/account_activationcode
index.php/Index/account_activation<b>/</b>code

Also, instead of hardcoding the link to localhost, you can use site_url() so uploading your application to live server doesn't mean you have to manually change all your links.
#4

[eluser]Xeroxeen[/eluser]
[quote author="Pert" date="1371560105"]The link should probably be

anchor('http://localhost/mySite/index.php/Index/account_activation<b>/</b>'.$activationCode,'Confirmation Register')

index.php/Index/account_activationcode
index.php/Index/account_activation<b>/</b>code

Also, instead of hardcoding the link to localhost, you can use site_url() so uploading your application to live server doesn't mean you have to manually change all your links.[/quote]

Thanks for the reply.I did that way also.But it didn't worked.Anyway i'll check it again.And other urls i have put base_url() function to get the url.for this i forgot to do that Smile thanks for showing me that too.
#5

[eluser]Xeroxeen[/eluser]
Now i put "/" again after the activation function in the url.Now it seems something happened.But now i get this error.Why is this?

Quote:A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '6a79cebaab8535eb9dfb7bc83d157dd3''' at line 1

SELECT email FROM `users` WHERE MD5(hash)=''6a79cebaab8535eb9dfb7bc83d157dd3''

Filename: C:\xampp\htdocs\mySite\system\database\DB_driver.php

Line Number: 330
#6

[eluser]Pert[/eluser]
Looks like you're putting quotes around the query and it doubles up. Try this instead (no single quotes around ?)

Code:
$val_code = "SELECT email FROM `users` WHERE hash=?";
#7

[eluser]Xeroxeen[/eluser]
[quote author="Pert" date="1371626306"]Looks like you're putting quotes around the query and it doubles up. Try this instead (no single quotes around ?)

Code:
$val_code = "SELECT email FROM `users` WHERE hash=?";
[/quote]

Thank you very much.Now it's working. I removed single quotations around hash and checked.But it didn't worked.Then i removed MD5 part also.Then it woked.Anyway i really appreciate your solution and this forum is really helpful.Thanks again Smile
#8

[eluser]Pert[/eluser]
Happy to help Smile
#9

[eluser]Xeroxeen[/eluser]
[quote author="Pert" date="1371630693"]Happy to help Smile[/quote]

I have another issue.If you free to check this is the link

http://ellislab.com/forums/viewthread/236174/




Theme © iAndrew 2016 - Forum software by © MyBB