[eluser]Phil Sturgeon[/eluser]
[quote author="easylancer" date="1195150608"]I have added in a forget password function into erkanaauth. This is as far as i got:
I can't seem to get the mail to work. The update function works but it won't email.[/quote]
In responce to our IM conversation, here is the code I was talking about.
Code:
function forgot($condition = array(), $length)
{
// Get the first and only key name in this array
list($field)=array_keys($condition);
// Use the key name to work out what to select
$this->CI->db->select($field);
// Use $condition[$field] to get the value
$query = $this->CI->db->getwhere('users', $condition[$field], 1, 0);
if ($query->num_rows != 1) {
return FALSE;
} else {
/*---------- Create a New Password ----------*/
$new = '';
for( $i = 1; $i <= $length; $i++ )
{
$new .= rand( 1, 9 );
}
$data = array(
'password' => $new
);
$this->CI->db->update('users', $data, $condition);
// The line below will be broken if its not an email you are sending it.
mail($condition, "New Password", "Your new password is: " . $new);
return TRUE;
}
}