CodeIgniter Forums
Noob needs help with email account verification - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Noob needs help with email account verification (/showthread.php?tid=43662)

Pages: 1 2


Noob needs help with email account verification - El Forum - 07-21-2011

[eluser]cpass78[/eluser]
If you dont have ci logging enabled, then something like /var/log/apache2/error.log should exist on your server


Noob needs help with email account verification - El Forum - 07-21-2011

[eluser]zulubanslee[/eluser]
error logs show only favicon file does not exist.


Noob needs help with email account verification - El Forum - 07-21-2011

[eluser]cpass78[/eluser]
could you post the entire controller starting with the class name and model being used or pm it one of us? By what you posted it 'looks' like it should function properly but thats only a small piece of the code. what is the exact error message displayed in the browser? do other parts of the site work properly?


Noob needs help with email account verification - El Forum - 07-21-2011

[eluser]zulubanslee[/eluser]
No problem. I appreciate you guys taking the time to help me with this. the createaccount function seems to be working fine.

Code:
<?php


class Login extends CI_Controller
{
    function __construct()
     {
         parent::__construct();            
     }
    
     function index()
     {
            
        $this->load->view('loginview');
     }
    
     function createaccount()
     {
            $this->load->library('email');            
            $this->load->library('form_validation');
            $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]|alpha_numeric|xss_clean');
            $this->form_validation->set_rules('username', 'Username', 'callback_username_check');
            $this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email');
            $this->form_validation->set_rules('emailrepeat', 'Repeat Email', 'trim|required|xss_clean|valid_email|matches[email]');
            $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|matches[passwordrepeat]');
            $this->form_validation->set_rules('passwordrepeat', 'Repeat password', 'trim|required|xss_clean');
            
            if($this->form_validation->run() == FALSE)
            {
                $this->load->view('/loginview');
            }
            else        
            {
                $username                =    $this->input->post('username');
                $email                    =    $this->input->post('email');
                $emailrepeat        =    $this->input->post('emailrepeat');
                $password                =    $this->input->post('password');
                $paswordrepeat    =    $this->input->post('passwordrepeat');
                
                $user_info = array($username, $email, $password);
                
                $this->load->model('usersmodel');
                
                //$rc is either fail message or security string to put into verification url
                $rc = $this->usersmodel->createaccount($user_info);
                
                if($rc == 'FAIL')
                {
                    $data['status'] = $rc;
                    $this->load->view('verifyaccountview', TRUE);
                }
                else
                {
                    
                    $this->email->from('[email protected]', 'Your Webmaster');
                    $this->email->to($email);
                    $this->email->subject('Verify your account with examples.com');
                    $this->email->message("Please click this link to verify your account: http://example.com/login/verifyaccount/$rc");
                    //$this->email->message("Please click this link to verify your account: http://example.com/login/verifyaccount?username=$username&security;_code=$rc");
                    
                    $email_rc = $this->email->send();
                    if($email_rc)
                    {
                        $data['status'] = 'You should be receiving an email in your inbox for verification. ';
                        $this->load->view('verifyaccountview', $data);
                    }
                    else
                    {
                        $data['status'] = 'Your registration was not successful';
                        $this->load->view('verifyaccountview', $data);
                    }
                }
            }
            
            function verifyaccount($security_code)
            {
                $this->load->model('usersmodel');
                $status = $this->usersmodel->verifyaccount($security_code);
                $data['status'] = $status;
                $this->load->view('verifyaccountview', $data);
            }
     }
    
    
     function username_check($username)
    {
        $sql_verify_username = $this->db->query("SELECT username FROM users WHERE username = '$username'");
        if ($sql_verify_username->num_rows() > 0)
        {
            $this->form_validation->set_message('username_check', 'This username is already in use.');
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }
    
    function loginuser()
    {
        /* $username    =    $this->input->post('username');
        $password    =    $this->input->post('userpassword');
        
        $this->load->model('usersmodel');
        $rc = $this->usersmodel->loginuser($username, $password);
        if($rc) */
        
    }

}

?>



Noob needs help with email account verification - El Forum - 07-21-2011

[eluser]zulubanslee[/eluser]
uh, i see the problem now. my function was embedded inside another one. F%*k me! Man thanks guys for the help. I apologize for having wasted your time.

In other matters, why didn't that return an error? I was entirely unaware that you could do that.


Noob needs help with email account verification - El Forum - 07-21-2011

[eluser]cpass78[/eluser]
Look at the position of the function verifyaccount. thats not right at all :p

Doh looks like you find it before me :p, not sure why that didnt report an error, that is strange.. Glad you got it sorted out though


Noob needs help with email account verification - El Forum - 07-21-2011

[eluser]zulubanslee[/eluser]
When I develop i use lots and lots of white space and in this case I lost track of a bracket. Live and learn.