php – codeigniter设置消息并插入时间错误
发布时间:2020-12-13 16:59:40 所属栏目:PHP教程 来源:网络整理
导读:我有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-lo
|
我有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",);
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
