Home Ask Login Register

Developers Planet

Your answer is one click away!

Rumiko February 2016

Need help creating registration/login form in CodeIgniter

So that we're on the same page, I'm following along with this tutorial:


Besides the starting CodeIgniter files, above is exactly what my code looks like. But here it is for those who can't view the link:

I have the model:

class user_model extends CI_Model
function __construct()
    // Call the Model constructor

//insert into user table
function insertUser($data)
    return $this->db->insert('user', $data);

//send verification email to user's email id
function sendEmail($to_email)
    $from_email = 'team@mydomain.com'; //change this to yours
    $subject = 'Verify Your Email Address';
    $message = 'Dear User,<br /><br />Please click on the below activation link to verify your email address.<br /><br /> http://www.example.com/user/verify/' . md5($to_email) . '<br /><br /><br />Thanks<br />Mydomain Team';

    //configure email settings
    $config['protocol'] = 'smtp';
    $config['smtp_host'] = 'ssl://smtp.mydomain.com'; //smtp host name
    $config['smtp_port'] = '465'; //smtp port number
    $config['smtp_user'] = $from_email;
    $config['smtp_pass'] = '********'; //$from_email password
    $config['mailtype'] = 'html';
    $config['charset'] = 'iso-8859-1';
    $config['wordwrap'] = TRUE;
    $config['newline'] = "\r\n"; //use double quotes

    //send mail
    $this->email->from($from_email, 'Mydomain');
    return $this->email->send();

//activate user account
function verifyEmailID($k        


wolfgang1983 February 2016

If your using codeigniter 3

You have your base url blank and that is why ::1 you can leave it blank will work most of the time but you may run it to error.

$config['base_url'] = '';

Set your base url.

$config['base_url'] = 'http://localhost/project/';

Or A Live Domain Example

$config['base_url'] = 'http://www.example.com/';


Check your controllers etc make sure your file name has first letter upper case and same with class. Example: User.php and class User extends CI_Controller {}

Post Status

Asked in February 2016
Viewed 2,167 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life