Welcome Guest, Not a member yet? Register   Sign In
E-mail function not working correctly
#11

[eluser]joshsmith[/eluser]
Yes you are correct. i have made those changes now, but still dont see activation code in the URL

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/' . $pass,'Confirmation Register'));
                //$this->email->send();
                echo 'Click the link below to activate your account' . anchor('http://localhost/codetwo/index.php/user/random_string/' . $pass,'Confirmation Register');
            //    echo " you have been registered $username";
                
            }
        }
            
    function random_string() {
        $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
        srand((double)microtime()*1000000);
        $i = 0;
        $pass = '';
        
        while ($i <= 7) {
            $num = rand() % 33;
            $tmp = substr($chars, $num, 1);
            $pass = $pass .$tmp;
            $i++;
        }
        
        return $pass;
    }
#12

[eluser]scottwire[/eluser]
You need to keep your variables straight. It should only be $pass in random_string() and only be $activation_code in register

in register() you need to change $pass to $activation_code

Code:
$activation_code = $this->random_string(10);

              $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/random_string/' . $activation_code,'Confirmation Register');
#13

[eluser]joshsmith[/eluser]
Thanks scottwire, i fixed my error and it worked.




Theme © iAndrew 2016 - Forum software by © MyBB