簡體   English   中英

忘記/重置密碼codeigniter問題

[英]forgotten / reset password codeigniter issue

我正在設置一個忘記的密碼並重置表格。 當我發送電子郵件時。 我有2個問題。 一是單擊鏈接時URL上沒有顯示唯一代碼 我遇到的另一個問題是Message: Undefined variable: message

其他所有內容都可以正常運行,但只是代碼未顯示在URL和$message錯誤中。

為什么沒有在URL中獲取我的$code 並有錯誤$message嗎?

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Forgotten extends MX_Controller {
private $error = array();

public function __construct() {
    parent::__construct();
    if ($this->user->hasPermissionAccess() == TRUE) {
        $this->lang->load('admin/english', 'english');
        $this->lang->load('admin/common/forgotten', 'english');
        $this->load->library('settings');
        $this->load->library('pagination');
        $this->load->library('request');
        $this->load->library('response');
        $this->load->library('document');   
    } else { 
        redirect('admin/error');
    }
}

public function index() {
    $this->document->setTitle($this->lang->line('heading_title'));

    if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {

        $this->load->library('email');

        $config['protocol'] = 'smpt';
        $config['smpt_host'] = 'ssl://squid.arvixe.com';
        $config['smpt_port'] = '465';
        $config['smpt_user'] =  '********'; // Username Blanked Out For Security
        $config['smpt_password'] = '******'; // Password Blanked Out For Security

        $this->email->initialize($config);

        $this->email->from($config['smpt_user']);
        $this->email->to($this->request->post['email']);
        $subject = sprintf($this->lang->line('text_subject'), $this->settings->get('config_name'));

        $this->email->subject($subject);

        $code = sha1(uniqid(mt_rand(), true));

        $this->load->model('admin/user/users_model');
        $this->users_model->editCode($this->request->post['email'], $code);

        $message .= sprintf($this->lang->line('text_greeting'), $this->settings->get('config_name')) . "\n\n";
        $message .= $this->lang->line('text_change') . "\n\n";
        $code = sha1(uniqid(mt_rand(), true));
        $message .= site_url('admin/reset/', $code) . "\n\n";
        $message .= sprintf($this->lang->line('text_ip'), $this->request->server['REMOTE_ADDR']) . "\n\n";
        $this->email->message($message);

        $this->email->send();
        echo $this->email->print_debugger();
    }

    $data['breadcrumbs'] = array();

    $data['breadcrumbs'][] = array(
    'text' => '<i class="fa fa-home"></i>' .' '.  $this->lang->line('text_home'),
    'href' => site_url('common/dashboard')
    );

    $data['breadcrumbs'][] = array(
    'text' => $this->lang->line('heading_title'),
    'href' => site_url('common/forgotten')
    );

    if (isset($this->error['warning'])) {
        $data['error_warning'] = $this->error['warning'];
    } else {
        $data['error_warning'] = '';
    }

    $data['action'] = site_url('admin/forgotten');

    $data['cancel'] = site_url('admin');

    $data['heading_title'] = $this->lang->line('heading_title');

    $data['text_your_email'] = $this->lang->line('text_your_email');
    $data['text_email'] = $this->lang->line('text_email');

    $data['entry_email'] = $this->lang->line('entry_email');

    $data['button_reset'] = $this->lang->line('button_reset');
    $data['button_cancel'] = $this->lang->line('button_cancel');

    return $this->load->view('common/forgotten', $data);
}

public function validate() {
    $this->load->model('admin/user/users_model');

    if (!isset($this->request->post['email'])) {
        $this->error['warning'] = $this->lang->line('error_email');
    } elseif (!$this->users_model->getTotalUsersByEmail($this->request->post['email'])) {
        $this->error['warning'] = $this->lang->line('error_email');
    }

    return !$this->error;

}
}

發現第一個$message所在的問題。 應該只是$message沒有句號。 對於代碼問題,我將site_url更改為base

$message = sprintf($this->lang->line('text_greeting'), $this->settings->get('config_name')) . "\n\n";
    $message .= $this->lang->line('text_change') . "\n\n";
    $code = sha1(uniqid(mt_rand(), true));
    $message .= base_url('admin/reset') . '/' . $code . "\n\n";
    $message .= sprintf($this->lang->line('text_ip'), $this->request->server['REMOTE_ADDR']) . "\n\n";
    $this->email->message($message);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM