473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

codeigniter flashdata

TheServant
1,168 Expert 1GB
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:
Expand|Select|Wrap|Line Numbers
  1. // Validation rules
  2. $this->form_validation->set_rules('name', 'username', 'required|alpha_dash');
  3. $this->form_validation->set_rules('pass', 'password', 'required|alpha_dash');
  4.  
  5. // Check form has been submitted with valid form info
  6. if ($this->form_validation->run()) {
  7.     $name = $this->input->post('name');
  8.     $pass = $this->input->post('pass');
  9.  
  10.     ...
  11.  
  12.     // Return if name and password was not found
  13.     if ($check===FALSE) {
  14.         $this->session->set_flashdata('message_type', 'warning');
  15.         $this->session->set_flashdata('message', 'Username not found.');
  16.     // Success
  17.     } else {
  18.         ...
  19.         $this->session->set_flashdata('message_type', 'information');
  20.         $this->session->set_flashdata('message', 'Logged in.');
  21.     }
  22.     // Success or fail redirect page
  23.     redirect('user/login'); exit();
  24. }
  25. // Load Page
  26. $this->load->view('v_user_login');
  27.  
view:
Expand|Select|Wrap|Line Numbers
  1. <?php if($this->session->flashdata('message')) : ?>
  2.     <div class="<?=$this->session->flashdata('message_type')?>">
  3.         <h3><span>&nbsp;</span><?=$this->session->flashdata('message')?></h3>
  4.     </div>
  5. <?php endif; ?>
  6.  
  7. <h1>User Login</h1>
  8. <?=form_open('user/login')?>
  9.     <?=form_fieldset('Login Form')?>
  10.  
  11.         <div class="textfield">
  12.             <?=form_label('Username','name')?>
  13.             <?=form_input('name', set_value('name'))?>
  14.             <?=form_error('name')?>
  15.         </div>
  16.  
  17.         <div class="textfield">
  18.             <?=form_label('Password', 'pass')?>
  19.             <?=form_password('pass')?>
  20.             <?=form_error('pass')?>
  21.         </div>
  22.  
  23.         <div class="buttons">
  24.             <?=form_submit('login', 'Login')?>
  25.         </div>
  26.  
  27.     <?=form_fieldset_close()?>
  28. <?=form_close()?>
Oct 22 '09 #1

✓ answered by Markus

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:

Expand|Select|Wrap|Line Numbers
  1. $this->message_type = ...
  2. /** ... */
  3. <?=$this->message_type;?>
  4.  

3 12677
Markus
6,050 Expert 4TB
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:

Expand|Select|Wrap|Line Numbers
  1. $this->message_type = ...
  2. /** ... */
  3. <?=$this->message_type;?>
  4.  
Oct 27 '09 #2
TheServant
1,168 Expert 1GB
Thanks mate.

**************************
Oct 28 '09 #3
Markus
6,050 Expert 4TB
@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).

Expand|Select|Wrap|Line Numbers
  1. Thanks                                                   mate.
  2.  
Oct 28 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
0
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...
5
bilibytes
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...
5
TheServant
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...
7
TheServant
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...
5
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...
2
dlite922
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...
2
vivekgs2007
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...
1
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...
0
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
0
BarryA
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.