[eluser]pisio[/eluser]
I'm so stupyd.
And I so sorry my English is not very good.
The problem was fixed before 5 mins.
Code:
function forgotpassword()
{
$step = $this->uri->segment(3);
$uid = $this->uri->segment(4);
if($step == NULL)
{
$step = 1;
}
if($step == 'nextstep')
{
$row = $this->db->query("SELECT * FROM `user` WHERE `name` = '{$_POST['name']}' OR `mail` = '{$_POST['mail']}' LIMIT 1 ");
foreach($row->result() as $ros)
{
$r = $ros->mail;
$id = $ros->id;
}
$length = 5;
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$string ='';
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
$msd = md5($string);
$new_pass = array('password'=>$msd,'active'=>'0');
$ws = "id = ".$ros->id;
$update = $this->db->update_string('user', $new_pass, $ws);
if($this->db->query($update))
{
$this->email->from('[email protected]', 'WikiScript');
$this->email->to($r);
$this->email->subject('Activate your acc.');
$text = 'http://localhost/wiki/index.php/userpage/forgotpassword/laststep/'.$id;
$text .= "\n\r New password is :{$string}";
$this->email->message($text);
$this->email->send();
$step = 2;
}
}
if($step == 'laststep'){
$data = array('active'=>'1');
$where = "id = '".$uid."' LIMIT 1 ";
$str = $this->db->update_string('user', $data, $where);
if($str){
$step = 3;
} else {
$step = 4;
}
}
$this->load->view('user_passrecovery',array('step' => $step));
}