php - insert a function forgot password Codeigniter

425

I need help to insert in the following site enter link description here a forgot function in Codeigniter. I try my self but give page not found. The form html:

The function in models:

class user_model extends CI_Model{
function __construct(){
    parent::__construct();
}

function validate($email , $password){
    $this->db->where('email',$email);
    $this->db->where('password',$password);
    $query=$this->db->get('user');
    if($query->num_rows==1){
        $row = $query->row();
        $data = array(
                'userid' => $row->userid,
                'fullname'=> $row->fullname,
                'profilepic'=> $row->profilepic,
                'validated' => true
                );
        $this->session->set_userdata($data);




        return "1";
    }
    return "0";



}

Controller:

class user extends CI_Controller{
    function __construct(){
    parent::__construct();
    $this->load->helper('url');

}
public function index(){
if(!$this->session->userdata('userid')){    
$this->load->view('user/login');
$this->load->view('header');
} 
else{

redirect('index.php/user/profile','refresh');
 }
 }

2sd Part:

public function login(){
$name=$this->security->xss_clean($this->input->post('username'));
$pass=$this->security->xss_clean($this->input->post('password'));
$this->load->model('user_model');
$status=$this->user_model->validate($name,$pass);
    echo $status;
    }
    function logout(){


$this->session->sess_destroy();
    redirect('index.php/user','refresh');

      }
314

Answer

Solution:

first of all replace your anchor to forgot password with this:

<a class="forgot" href="<?php echo base_url();?>index.php/user/resend_password">Forgot  password?</a>   

Then define a function with name resend_password inside user class:

 public function resend_password(){
   #your code here..
 }
786

Answer

Solution:

<a class="forgot" href="<?php echo site_url('user/resend_password/')?>Forgot  password?</a>

And you write a function resend_password in controller user

People are also looking for solutions to the problem: php - Wordpress error trying to login via wp-admin

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.