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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:24:12+00:00 2026-05-21T20:24:12+00:00

Lets say for example I am creating a an online shop. I have a

  • 0

Lets say for example I am creating a an online shop. I have a controller called products and within that controller I have a function called create_product. Create_product calls a view that displays a form where users get to enter new products into the database.

When the user fills in the form to create a product, should I send the action back to the create_product controller and handle it with an IF statement? or offload to another function?

Example

<form method="post" action="www.example.dev/products/create_product/add"> 
//the above form would post back to the original controller

function create_product()
{
    if(uri->segment(3) == "add")
    {
        //call a model to do all the database stuff
    }

    load->view->create_product_form;
}

Is this the best way to handle this or should I be passing it off to another function?

  • 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-21T20:24:12+00:00Added an answer on May 21, 2026 at 8:24 pm

    Don’t cram a ton of stuff in one function using the URI segment to filter it. createProduct() can list the products available for creation (in a CRUD format, I assume), and the submission of the form should ping another controller with the POSTed data. Perhaps insertProduct(), where the data is sanitized and sent to the model for insertion to the database.

    Separation of concerns! Keep the functions as separate as possible with good descriptors for the names of the functions.

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

Sidebar

Related Questions

Here is my scenario. For the example lets say that I need to return
My simplified and contrived example is the following:- Lets say that I want to
This is a contrived example, but lets say I have declared objects: CustomObj fooObj;
Lets say I have a table containing several hundred million rows that looks something
Lets say I have this class (just as an example): internal class Packet {
If I was to send a URL to a DNS server, lets say: dev.example.com/?username=daniel,
Lets say I am currently at: http://example.com/folder/page.html Is it possible to create a relative
As an example, lets say I wanted to list the frequency of each letter
I have two websites, let's say they're example.com and anotherexample.net . On anotherexample.net/page.html ,
For Example: Let's say that I want to return a view that displays 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.