php – codeigniter设置消息并插入时间错误

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – codeigniter设置消息并插入时间错误脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我有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上加载set消息,但问题是我正在使用该页面与其他东西进行验证错误而且我也希望此消息显示函数是否不存在工作.这是观点.

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

我认为第一个echo 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",);

脚本宝典总结

以上是脚本宝典为你收集整理的php – codeigniter设置消息并插入时间错误全部内容,希望文章能够帮你解决php – codeigniter设置消息并插入时间错误所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。