Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6073715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:18:06+00:00 2026-05-23T10:18:06+00:00

I am using CodeIgniter 1.7.1.Ok here is the scenario.When ever the form is submitted,i

  • 0

I am using CodeIgniter 1.7.1.Ok here is the scenario.When ever the form is submitted,i need to do two things

1) persist the value selected in dropdown.
2) using session->set_flashdata(),i need to set the custom database message.

Now as we know,we need to redirect before this flash data can be set.

This is the code which i have written.

if ($this->form_validation->run() == TRUE){

    $this->session->set_flashdata(‘msg’, ‘Taha Hasan’); 
    redirect(current_url());

    $this->ShowReceiveInventoryView();
}

Also i m using set_select in the dropdown view to persist the value.

<select name=“myselect”>
<option value=“one” <?php echo set_select(‘myselect’, ‘one’, TRUE); ?> >One</option>
<option value=“two” <?php echo set_select(‘myselect’, ‘two’); ?> >Two</option>
<option value=“three” <?php echo set_select(‘myselect’, ‘three’); ?> >Three</option>
</select>

Now here is the problem…The flash message appears BUT because i am redirecting to the current page,the drop down set_select value is lost !!! Default value appears in the selection :(..If i remove the redirect line in the code,the dropdown value is presisted but Flash data is not set !!!

Hope you guys have a solution to this problem…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:18:06+00:00Added an answer on May 23, 2026 at 10:18 am

    set_select() only works when the $_POST array has content (as you’ve discovered), but your redirect is obviously a GET request.

    The proper way to handle this is to perform your query within the Controller, passing the object that is being edited to your view. Within your view you then repopulate your form, or set default values, based on $_POST if it exists or based on the passed object.

    Let’s assume we are editing a product, which has the myselect (a horribly named field) property. We will use PHP’s ternary operator to test if the value of the product’s myselect parameter is equal to the current option – if so, we’ll use set_selects()‘s third parameter to set the default.

    <option value="one" <?php echo set_select('myslect', 'one', ((!$product) || !$this->input->post('myselect') && $product->myselect == 'one' ? TRUE : FALSE); ?>One</option>
    
    <option value="two" <?php echo set_select('myselect', 'two', (!$this->input->post('myselect') && $product->myselect == 'two' ? TRUE : FALSE); ?>Two</option>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using CodeIgniter's form validation . Here is an example: $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
I am using Codeigniter framework and I have a form with input fields. When
I am using codeigniter and Jquery. I have an upload form in my view
I am developing an app using Codeigniter. In this app I got a form
I am using Codeigniter's validation class to validate my form. Could you please tell
Newbie here. I'm using codeigniter and mysql How can I dynamically (number of names
I'm using CodeIgniter and I came across an interesting problem. I need to use
I have this code here in PHP using Codeigniter framework, I can't seem to
I am using Codeigniter to build my project. Here i have some doubts or
I am using Uploadify to upload Files and using Codeigniter framework. Here is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.