• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forget password

#1
[eluser]Niube[/eluser]
hi i'm new here so if i do wrong in this forum,please let me know first...
Big Grin

okey back to topic,if i forget the password what code must i change?i try to find in proces login but i can't find one...Here the code.

function process_login()
{
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');

if ($this->form_validation->run() == TRUE)
{
$username = $this->input->post('username');
$password = $this->input->post('password');

if ($this->Login_model->check_user($username, $password) == TRUE)
{
$data = array('username' => $username, 'login' => TRUE);
$this->session->set_userdata($data);
redirect('absen');
}
else
{
$this->session->set_flashdata('message', 'Maaf, username dan atau password Anda salah');
redirect('login/index');
}
}
else
{
$this->load->view('login/login_view');
}
}

Please Help me out...
Smile

#2
[eluser]cideveloper[/eluser]
From the sounds of it you don't remember the password to login to the web application. From the looks of it your application is using a model called Login_model to probably check the database you are connecting to. Check the file called login_model.php in application/models/ and see what table is being queried. Then use phpmyadmin to login to the database. If you dont know what the main password for the database is, you can find that in your database.php file in application/config/ directory.

#3
[eluser]Niube[/eluser]
So im in phpmyadmin now,and i found the table it caled user so what i must change in that table??
(Sry i just bought book codeightner yesterday,so i didn't know much)
>.<

#4
[eluser]cideveloper[/eluser]
In the table user there must be some fields like username and password. The issue you might come up with is that the password might be encoded or encrypted. If the passwords you see in phpmyadmin are a bunch of random wierd letters and numbers and characters you cant just change the password in the database. I can help if you post the code from Login_model.php function check_user. That will show you how the password is checked. You might see code like this

Code:
$this->CI->encrypt->decode($password_field_in_db)

#5
[eluser]Niube[/eluser]
This is it sir....

function check_user($username, $password)
{
$query = $this->db->get_where($this->table, array('username' => $username, 'password' => $password), 1, 0);

if ($query->num_rows() > 0)
{
return TRUE;
}
else
{
return FALSE;
}
}
}

is that possible if we can't just change the password from line $query = $this->db->get_where($this->table, array('username' => $username, 'password' => $password), 1, 0);??

#6
[eluser]cideveloper[/eluser]
yes you can change it in here. This is how it will work. I am assuming you know your username and that username is in the table user in the database. What will happen here is that you will try to log in with the wrong password but the check process will change the password to the one you entered and then should log you in.

As soon as you have done that you will need to remove the extra code in the model.

Code:
function check_user($username, $password)
    {
        //Remember to remove the below line once you have logged in once. VERY IMPORTANT!!!
        $this->db->update($this->table, array('password' => $password), array('username' => $username));
        //Remember to remove the above line once you have logged in once. VERY IMPORTANT!!!

        $query = $this->db->get_where($this->table, array('username' => $username, 'password' => $password), 1, 0);
        if ($query->num_rows() > 0){
            return TRUE;
        }else{
            return FALSE;
        }
    }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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