Reputation: 1472
I have 2 problems to solve. First I have this small function
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');
}
I only pasted the code which was necessary so when verified fails, I want to load the set message on the forgetpasswordview but the problem is I am using that page for validation errors with other things and I also want this message to show if this function doesnt work. Here is the view.
<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>
I thought that the first echo validation_errors might take care of the token_expired but ofcourse doesnt work, and the second validation works when I check if the email is undergoes validation.
My second problem is that, I have a function which works but inserting current time + 15 minutes. I am in helsinki/Finland so I use it like this.
function __construct(){
parent::__construct();
date_default_timezone_set('Europe/Helsinki');
......and in the function its
$data = array(
'expiration' => date("Y-m-d h:i:s", strtotime("+15 minutes")),
);
But the problem with that is it works fine till 12PM but when its 1pm it should dis play 13:15:00 but it shows 01:15:00 So need to fix that problem as well.
Upvotes: 4
Views: 429
Reputation: 2408
You can not set form validation message without submitting form intead pass a variable to your view
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');
}
And in view
if(isset($token_expired) && $token_expired != '')
{
echo $token_expired;
}
For your second problem
$data = array(
'expiration' => date("Y-m-d H:i:s", strtotime("+15 minutes")),
);
Upvotes: 3