Я пытаюсь написать функцию сброса пароля в php codeigniter php, и не обращайте внимания на то, с чего начать и какой лучший способ сделать это, пожалуйста, помогите
my db as like this
CREATE TABLE `members` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`verifystring` varchar(15) NOT NULL,
`lostkey` varchar(100) NOT NULL,
`active` enum('0','1') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
и функция работает следующим образом
// забыли пароль
public function forget_password(){
$this->form_validation->set_rules('email','Email Address','xss_clean|required|valid_email|callback_reset_password');
if($this->form_validation->run() == FALSE){
$this->load->view('account/forget_password');
}else{
//send an email
$this->load->library('email');
$this->email->set_newline("\r\n");
$this->email->from('me@gmail.com', 'Raju');
$this->email->to('me@gmail.com');
$this->email->subject('Email my');
$key = 12334455;
$message = "Please click this url to change your password ". base_url()."reset_now/".$key ;
$message .="<br/>Thank you very much";
$this->email->message($message);
if($this->email->send())
{
echo 'Please check your email to reset password.';
}
else
{
show_error($this->email->print_debugger());
}
}
}
//email check for forget password
function reset_password($email){
$query = $this->db->get_where('members', array('email'=>$email));
if(!$query->num_rows()>0){
$this->form_validation->set_message('forget_email_check', 'The %s does not exists in our database');
return FALSE;
}else{
//check database fields
/*
$this->db->where('email', $email);
$this->db->limit(1);
$Q = $this->db->get('members');
if($Q->num_rows()>0){
$data = $Q->result_array();
echo $data[0]['username'].'<br/>';
echo $data[0]['password'].'<br/>';
}
*/
echo '<br/>'. $email.'<br/>';
}
//$query->free_result();
//return true;
}