Hello community of EE!
I’ve got this problem which I hope some of you might be able to help me with.
I’m trying to make it possible to change password from outside the pre-made member templates, and this is the code I’ve got so far, for the insert file.
But I’m not sure what encrypting EE uses, so I was wondering if someone could help a fella out abit.
Also, I know the code is not optimal, I will sort that out once I get it to work.
<?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);
}
?>Thanks in advance
/Jeff