Hello, I’m trying to make it possible for members to change their password.
<?php
$uid = $this->EE->input->post('uid');
$result_pass = $this->EE->db->query("SELECT password, crypt_key FROM exp_members WHERE unique_id = '$uid'");
$key = $result_pass->row('crypt_key');
$oldpassword = $result_pass->row('password');
$encrypt_pass = $this->encrypt->decode($oldpassword, $key);
$oldpass_insert = $this->EE->input->post('oldpassword');
$password = sha1($this->EE->input->post('password'));
$password_conf = sha1($this->EE->input->post('password_confirm'));
$results = $this->EE->db->query("SELECT member_id FROM exp_members WHERE unique_id = '$uid'");
$member_id = $results->row('member_id');
$data = array(
'password' => $password
);
if ($oldpassword == $oldpass_insert)
{
if ($password == $password_conf)
{
if ($results->num_rows() > 0)
{
$sql = $this->EE->db->update_string('exp_members', $data, "member_id = $member_id");
$this->EE->db->query($sql);
$this->EE->session->set_flashdata('result_message', 'test1.');
$this->EE->functions->redirect('/parents_utv/profil/'.$uid);
}else{
$this->EE->session->set_flashdata('result_message', 'test2.');
$this->EE->functions->redirect('/parents_utv/profil/'.$uid);
}
}
}
else
{
$this->EE->session->set_flashdata('result_message', $oldpassword.'
'. $oldpass_insert );
$this->EE->functions->redirect('/parents_utv/profil/'.$uid);
}
?>But I’m not quite sure what encryption the password already have, therefor I get an error on my first if statement.
To make a long story short, how do I encrypt a password the same way EE already does it?
Thanks in advance
Jeff