插入功能忘记密码Codeigniter

时间:2014-04-05 11:05:03

标签: php codeigniter

我需要帮助才能在以下网站enter link description here中插入Codeigniter中的忘记功能。我尝试自己,但没有找到页面。 表格html:

<div class="callout-copy">
  <h1>Welcome To Kea Talks.</h1>
  <p>Kea talks helps you to connect and share with the people in your Kea life.</p>
  <img class="logo" src="<?php echo base_url();?>assets/css/images/logo1.png" alt="logo">
</div>
</div>
<div class="front-signin js-front-signin">
<form action="<?php echo base_url();?>index.php/user/signin" class="signin" method="post"  id="signin">
<div class="username">
  <input type="text" id="signin-email" required class="text-input email-input" name="email" autocomplete="on" placeholder="Email">
  </div>
 <table class="flex-table password-signin">
  <tbody>
  <tr>
    <td class="flex-table-primary">
      <div class="password flex-table-form">
        <input type="password" id="signin-password" required class="text-input flex-table-input" name="password" placeholder="Password">
      </div>
    </td>

    <td class="flex-table-secondary">
      <button type="submit" class="submit btn primary-btn flex-table-btn js-submit">
        Sign in
      </button>
    </td>
    </tr>
    </tbody>
    </table>
    <div class="remember-forgot">
    <span class="separator">·</span>
    <a class="forgot" href="<?php echo base_url();?>index.php/user/resend_password.php">Forgot  password?</a>
    </div>
    </form>

模特中的功能:

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";



}

控制器:

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部分:

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');

      }

2 个答案:

答案 0 :(得分:4)

首先将您的锚替换为忘记密码:

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

然后在用户类中定义名为resend_password的函数:

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

答案 1 :(得分:1)

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

您在控制器用户

中编写了一个函数resend_password