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 7744459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:46:22+00:00 2026-06-01T09:46:22+00:00

I am having troubles passing data from the controller to the model in opencart(1.5.3).

  • 0

I am having troubles passing data from the controller to the model in opencart(1.5.3). I have modified the ‘add products’ form to include a file input field, however, the results I am experiencing, I don’t understand, so I’d appreciate any input, or suggestions as to a solution.

When I post the form, the data is sent to the controller, but the controller does not pass it to the model, which stops the final database query from being executed.

Im not sure if this is part of this issue, but in firebug, the post data is defined in the source list, but the field name is not defined in the parts list.

Below is an example of the code. It might be worth mentioning that I am using VQmod to add changes on the fly.

View:

      <table class="form">
        <tr>
          <td><?php echo $entry_product_pins; ?></td>
          <td><input type="file" name="product_pins" /><?php echo $tab_pins_instructions; ?>
      </td>
        </tr>
   </table>

Controller:

    if (isset($this->request->files['product_pins']['tmp_name'])) {

    $this->data['product_pins'] = file_get_contents($this->request->files['product_pins']['tmp_name']); 

                    } else {

    $this->data['product_pins'] = '';

   }

Model:

            if ( isset($this->data['product_pins']) ) {

                foreach (explode(";\n", $this->data['product_pins']) as $pin) {

                $this->db->query("INSERT INTO " . DB_PREFIX . "product_pins SET pin_product_id = '" . (int)$product_id . "', pin_pin_number = '" . $this->db->escape($pin) . "'");
              }

            } else { 

// added for debugging

exit("product_pins not set"); }
  • 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-01T09:46:23+00:00Added an answer on June 1, 2026 at 9:46 am

    Form Submission -> post data validation -> passed to model is the path in theory. What you need to do is take the pins from the $this->request->files and put it into the post data when you validate (at least that’s the way I would do it), or pass the filename to the model method and extract it in the model, though that tends to get a little trickier then

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

Sidebar

Related Questions

I am having trouble passing data read from a text file to another class
CakePHP Newbie :) I am having trouble accessing another controller and passing that data
I am having trouble passing data retrieved from a $.post() function to use in
I am having trouble nailing down the best method for passing data from a
I am having trouble passing data from one activity to another. I can easily
i'm still transitioning from as2 to as3, i'm having trouble with parsing XML data
I am having troubles migrating from OC4J 10.1.2.3 to 10.1.3.1.4. The problem is for
I'm new to ASP.NET MVC; something I'm having trouble with is getting data from
I'm having some trouble with Java's Calendar. I'm parsing some data from a txt
I'm having trouble loading data from sqlite database into a detailed view. The table

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.