• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Noob needs help with email account verification

#14
[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) */
        
    }

}

?>


Messages In This Thread
Noob needs help with email account verification - by El Forum - 07-19-2011, 02:17 PM
Noob needs help with email account verification - by El Forum - 07-20-2011, 11:55 AM
Noob needs help with email account verification - by El Forum - 07-20-2011, 12:44 PM
Noob needs help with email account verification - by El Forum - 07-20-2011, 02:39 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 05:15 AM
Noob needs help with email account verification - by El Forum - 07-21-2011, 05:21 AM
Noob needs help with email account verification - by El Forum - 07-21-2011, 10:48 AM
Noob needs help with email account verification - by El Forum - 07-21-2011, 10:49 AM
Noob needs help with email account verification - by El Forum - 07-21-2011, 01:05 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 01:59 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 02:08 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 02:26 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 02:33 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 02:37 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 02:42 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 02:44 PM
Noob needs help with email account verification - by El Forum - 07-21-2011, 02:52 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.