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

  • SEARCH
  • Home
  • 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 9279133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:33:26+00:00 2026-06-18T17:33:26+00:00

Basically I want my multi-part form’s controller to have a single function that gives

  • 0

Basically I want my multi-part form’s controller to have a single function that gives the post data to the other functions like preview and edit.

The function is below:

function get_post_data()
{
  $post_data_array = array();
  // declaration of all form field names
  $variable_array = array('form_field_1', 'form_field_2', ... 'form_field_n');

  for ($i = 0; $i < count($variable_array); $i++) {
    $variable_value = $this->input->post($variable_array[$i]);
    // turn them into an easy-to-use array
    $post_data_array[$variable_array[$i]] = $variable_value;
  }
  return $post_data_array;
}

So that functions will access it as:

function show_preview_form()
{
  $this->load->view('preview_form_view', $this->get_post_data() );
}

function send_to_database()
{
  $data_array = $this->get_post_data();
  $this->Model->insert_to_database($data_array['form_field_1'], ...);
}

Currently it does not work. Firebug returns a 500 Internal Status Error status. Do you guys know how to solve this?

I really don’t want to repeat the long get_post_data in every function that needs it.

  • 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-06-18T17:33:27+00:00Added an answer on June 18, 2026 at 5:33 pm

    you need to assign a empty array to $post_data_array before can add values to it.

    in the beginning of get_post_data function add $post_data_array = array();

    update:

    its probably also a good idea to change get_post_data to _get_post_data that way its not accessible directly from the url.
    http://ellislab.com/codeigniter/user-guide/general/controllers.html#private

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I have a control that I want to extend from the Selector Class
I want to know how i can post a multi-dimensional array? Basically i want
I want to have simple program in python that can process different requests (POST,
I basically want the same functionality as facebook, twitter and all those other infinite
I basically want to open a browser window from Word using VBA that does
This is a multi-part question. I have a table similar to: CREATE TABLE sales_data
Basically, I have a multi-module project consisting of 5 different modules. One of the
I have a php form and I want to display or hide certain fields
I have a form, basically to upload a file. I am submitting the form
I've started looking into multi-threading in Ruby. So basically, I want to create a

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.