5
Tôi có lớp để đặt lại mật khẩu người dùng. Nhưng mã luôn mang lại cho tôi một lỗi:Gọi để xác định chức năng trên Codeigniter
Fatal error: Call to undefined function newRandomPwd() in
C:\AppServ\www\phonebook\application\controllers\reset.php
on line 32
Dưới đây là mã của tôi:
class Reset extends CI_Controller{
function index(){
$this->load->view('reset_password');
}
function newRandomPwd(){
$length = 6;
$characters = 'ABCDEF12345GHIJK6789LMN$%@#&';
$string = '';
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
function resetPwd(){
$newPwd = newRandomPwd(); //line 32, newRandomPwd()
//is undefined
$this->load->library('form_validation');
$this->load->model('user_model');
$getUser = $this->user_model->getUserLogin();
if($getUser)
{
$this->user_model->resetPassword($newPwd);
return TRUE;
} else {
if($this->form_validation->run()==FALSE)
{
$this->form_validation->set_message('','invalid username');
$this->index();
return FALSE;
}
}
}
}
Làm thế nào để thực hiện phương pháp newRandomPwd
sẵn vì vậy nó không xác định?
Tôi mới đến MVC .. cảm ơn bạn đã giúp đỡ của bạn. Nó hoạt dộng bây giờ! – softboxkid
+1 Cảm ơn bạn đã nhắc tôi về toàn cầu và đối tượng – Anthony