Can anyone tell me why flashdata is not immediately available? Is it only available once the page has been resent? I am using form validation for form fields and flashdata for error messages. If there is an error I want the fields to be filled in with the $_POST data, which CI does easily, however, the flashdata seems to only be recognised once I refresh (through redirect()) which destroys the $_POST data.
If I remove the redirect then validation errors and automatic re-entering of posted values works, but no flashdata message.
controlller: - // Validation rules
-
$this->form_validation->set_rules('name', 'username', 'required|alpha_dash');
-
$this->form_validation->set_rules('pass', 'password', 'required|alpha_dash');
-
-
// Check form has been submitted with valid form info
-
if ($this->form_validation->run()) {
-
$name = $this->input->post('name');
-
$pass = $this->input->post('pass');
-
-
...
-
-
// Return if name and password was not found
-
if ($check===FALSE) {
-
$this->session->set_flashdata('message_type', 'warning');
-
$this->session->set_flashdata('message', 'Username not found.');
-
// Success
-
} else {
-
...
-
$this->session->set_flashdata('message_type', 'information');
-
$this->session->set_flashdata('message', 'Logged in.');
-
}
-
// Success or fail redirect page
-
redirect('user/login'); exit();
-
}
-
// Load Page
-
$this->load->view('v_user_login');
-
view: - <?php if($this->session->flashdata('message')) : ?>
-
<div class="<?=$this->session->flashdata('message_type')?>">
-
<h3><span> </span><?=$this->session->flashdata('message')?></h3>
-
</div>
-
<?php endif; ?>
-
-
<h1>User Login</h1>
-
<?=form_open('user/login')?>
-
<?=form_fieldset('Login Form')?>
-
-
<div class="textfield">
-
<?=form_label('Username','name')?>
-
<?=form_input('name', set_value('name'))?>
-
<?=form_error('name')?>
-
</div>
-
-
<div class="textfield">
-
<?=form_label('Password', 'pass')?>
-
<?=form_password('pass')?>
-
<?=form_error('pass')?>
-
</div>
-
-
<div class="buttons">
-
<?=form_submit('login', 'Login')?>
-
</div>
-
-
<?=form_fieldset_close()?>
-
<?=form_close()?>
Hi, The Servant - sorry for the late reply.
Yes, flash data is only available to the *next* server request.
For this instance, you might just set some dynamic object properties: -
$this->message_type = ...
-
/** ... */
-
<?=$this->message_type;?>
-
3 12677
Hi, The Servant - sorry for the late reply.
Yes, flash data is only available to the *next* server request.
For this instance, you might just set some dynamic object properties: -
$this->message_type = ...
-
/** ... */
-
<?=$this->message_type;?>
-
Thanks mate.
**************************
@TheServant
No problem, dude. BTW, to overcome that 'message too short' problem, just stick a lot of space between your words (the software isn't smart enough to strip it out - lol). Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gerry Vandermaesen |
last post by:
Hi,
I was looking into CodeIgniter, and encountered the following problem:
In codeigniter, you could create a new controller like this:
---
class People extends Controller {
function...
|
by: surfivor |
last post by:
I am doing some preliminary research as we are slated to do a project
with wordpress. I looked at the wordpress code and realized why I like
MVC so much (Rails) because the code mixed in with the...
|
by: bilibytes |
last post by:
Hi,
(I don't really know where to post this question)
for readability : LSWS = Large Scale Web Sites
by LSWS I mean:
- flickr
-facebook
-myspace
... web sites that are quite social...
|
by: TheServant |
last post by:
I have recently (today) started doing something worthwhile on CodeIgniter, which is fantastic BTW. I have a problem and I can't figure out what is going wrong. I will post what I have now, but this...
|
by: TheServant |
last post by:
Hi all,
I am trying to do something in CI which I cannot find any documentation for. I have set up my .htaccess so that if a file does not exist, and no controller/function is called it goes to the...
|
by: handoyo |
last post by:
Hi all,i'm trying to show updated data in existing html td.. For example i got column that show last modified datetime,then i want to update data again,the column will changed to current time without...
|
by: dlite922 |
last post by:
I just picked CodeIgniter for a pet project just to learn yet another framework to put on my resume.
Question I came up with while starting is in my previous framework, I could load a (by...
|
by: vivekgs2007 |
last post by:
hi to all,
I am using the php from last 1 year…this is my first framework i am using i downloaded CodeIgniter and made the configaration as listed above..i am also using wamp server..
I am getting...
|
by: kiranvn31 |
last post by:
Hi
I create page in C# asp.net
In that page I write code for change flash dynamically
My flash file located in one folder name as "FlashData" and i call this file in html file
And I call...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |