代码点火器设置消息和插入时间错误


codeigniter set message and inserting time error

我有2个问题要解决。首先我有这个小函数

if(!$verified) {
            $this->db->trans_rollback();
            $this->form_validation->set_message('token_expired', 'Token expired try again.');
            $this->load->view('header');
            $this->load->view('forgot_password_view');
            $this->load->view('footer');
            }

我只粘贴了必要的代码,所以当验证失败时,我想在 forgetpasswordview 上加载设置的消息,但问题是我正在使用该页面进行验证错误和其他事情,我也希望此消息显示如果此功能不起作用。这是视图。

<div class="well">
        <?php echo validation_errors(); ?>
        <?php 
        if(validation_errors() != false) 
        { 
            echo '<div class="form-group alert alert-danger has-error">';
                echo'<ul>';
                    echo validation_errors('<li class="control-label">', '</li>');
                echo'</ul>';
            echo '</div>';   
        }
        ?>
        <?php echo form_open('login/reset_password'); ?>
        <h1>Forgot your password?</h1>
        <p>Please enter your email address so we will send you a link to change your password</p>
        <div class="<?php if(form_error('email')!= null){echo ' has-error';} ?>">
        <input  name="email" style="width: 20%" class="form-control" type="email" placeholder="Enter your email Address"/>
        <button style="margin-top:20px;" class="btn btn-default" type="submit" name="submit">Submit</button>
    </div>
    </div>

我认为第一个回显validation_errors可能会处理token_expired但当然不起作用,当我检查电子邮件是否经过验证时,第二个验证有效。

我的第二个问题是,我有一个有效的功能,但插入当前时间 + 15 分钟。我在赫尔辛基/芬兰,所以我这样使用它。

 function __construct(){
        parent::__construct();
        date_default_timezone_set('Europe/Helsinki');

......并在函数中其

$data = array(
         'expiration' => date("Y-m-d h:i:s", strtotime("+15 minutes")),
         );

问题是它工作正常到中午 12 点,但当下午 1 点时,它应该播放 13:15:00,但它显示 01:15:00 所以也需要解决这个问题。

如果不提交表单,则无法设置表单验证消息,并将变量传递给您的视图

if(!$verified) 
{
    $this->db->trans_rollback();
    $message['token_expired']= 'Token expired try again.';//(token_expired)?'Token expired try again.':'';
    $this->load->view('header');
    $this->load->view('forgot_password_view', $message);
    $this->load->view('footer');
}

在视野中

if(isset($token_expired) && $token_expired != '') 
{  
    echo $token_expired;
}

对于你的第二个问题

$data = array(
             'expiration' => date("Y-m-d H:i:s", strtotime("+15 minutes")),
             );