Welcome Guest, Not a member yet? Register   Sign In
The function there is in the same module, but apache gives me Fatal error: Call to undefined function
#1

[eluser]linderox[/eluser]
I read an artilce about auth module and decided to make my own function for encryption password, but my server said that when I want submit my register form.how to solve that problem?
Code:
Fatal error: Call to undefined function encryptpass() in Z:\home\rb.ci\www\ddsfwk233\application\models\users.php on line 29

Code:
<?php

class Users extends Model {
    
    function Users()
    {
        // Call the Model constructor
        parent::Model();
    }

    function encryptpass($password)
    {
        // one way
        // return sha1($password.$this->config->item('encryption_key'));
        
        //more secure way.It's encrypt password with hashed password
        $msalt = $this->config->item('encryption_key');
          $fsalt = hash('sha512', $msalt.$password);
          $bsalt = hash('sha512', $password.$msalt);
          $pass_hash = hash('sha512', $fsalt.$pass.$bsalt);

          return $pass_hash;
    }
        
    function register($username, $password)
    {
        $new_user = array (
            'username'=>$username,
            'password'=> encryptpass($password)
        );

        $this->db->insert('users', $new_user);

        return true;
    }
    
    function login($username, $password)
    {
        $encrypt_password = encryptpass($password);
        $query = $this->db->get_where('users', array('username'=>$username, 'password'=>$encrypt_password));

        if ($query->num_rows()==0) return false;
        else{
            $result = $query->result();
            $userid = $result[0]->uid;

            return $userid;
        }

    }

}
#2

[eluser]linderox[/eluser]
i found error. it wasn't global! I can't use it like this

$this->encryption




Theme © iAndrew 2016 - Forum software by © MyBB