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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:57:40+00:00 2026-06-12T09:57:40+00:00

I have a simple crud application with Codeigniter. I’m still trying to learn the

  • 0

I have a simple crud application with Codeigniter. I’m still trying to learn the framework. But I’m getting an error in the Update Controller and can’t seem to find it.

The Three Errors I’m getting are:

Severity: Warning
Message: Missing argument 1 for Customers::update_customer()
Filename: controllers/customers.php
Line Number: 67

Severity: Notice
Message: Undefined variable: id
Filename: controllers/customers.php
Line Number: 94

And this last one is a result of the form action.

Severity: Notice
Message: Undefined index: id
Filename: views/edit_customer.php
Line Number: 16
” method=”post”>


CONTROLLER:

function update_customer($id){

    $data['success']=0;
    if($_POST){
        $data_customer=array(
            'first_name'=>$_POST['first_name'],
            'last_name'=>$_POST['last_name'],
            'phone'=>$_POST['phone'],
            'email'=>$_POST['email'],
            'website'=>$_POST['website'],
            'business_name'=>$_POST['business_name'],
            'business_add'=>$_POST['business_add'],
            'business_cityState'=>$_POST['business_cityState'],
            'cc_type'=>$_POST['cc_type'],
            'cc_number'=>$_POST['cc_number'],
            'cc_exp'=>$_POST['cc_exp'],
            'cc_cvd'=>$_POST['cc_cvd'],
            'billing_add'=>$_POST['billing_add'],
            'billing_zip'=>$_POST['billing_zip'],
            'package'=>$_POST['package'],
            'assigned_zip_code'=>$_POST['assigned_zip_code'],
            'active'=>1
        );
        $this->customer->update_customer($id,$data);
        $data['success']=1;
    }
    $data['customer']=$this->customer->get_customer($id);

    $this->load->view('header');
    $this->load->view('edit_customer',$data);
    $this->load->view('footer');
}

MODEL:

function update_customer($id, $data){
    $this->where('id', $id);
    $this->db->update('customers', $data);
}

TOP OF THE VIEW:

    <?php if($success==1){ ?>
        <div class="successAlert">This customer has been updated.</div>
    <? } ?>

    <div class="mainForm">
        <?php echo validation_errors(); ?>

        <form action="<?=base_url()?>customers/update_customer/<?=$customer['id']?>" method="post">

            <label for="first_name">First Name:</label> 
            <input type="input" name="first_name" value="" /><br />
            <hr>
  • 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-12T09:57:42+00:00Added an answer on June 12, 2026 at 9:57 am

    1. You’re cloning an array key for key: bad

    Why bother constructing the $data_customer array like this? The end result looks identical to $_POST anyway with the exception of the added 'active' key.

    If you really want to clone the array, just write:

    $data_customer = $_POST;
    $data_customer['active'] = 1;
    

    This is, of course, a lot more resistant to changes in the values you are submitting to the server too. If you decide to send, for instance, the middle name in the future, it requires zero maintenance.

    2. if($_POST)…

    if($_POST) will always return TRUE because $_POST is a global, the if will always execute. You’d be better to use CodeIgniter’s $this->input->post(), which returns FALSE if a the user did not submit post data.

    3. Your Errors

    You need to pass an id into the update_customer() function. This can be accomplished by sending the POST request to http://localhost/your_app/customers/update_customer/5, as an example.

    Or, you could attach the id as a hidden value in the form using <input type='hidden' name='id' value='5'/> and then retrieve it in the $this->input->post() array as well and remove the $id parameter from update_customer($id).

    That will clear up your first two errors.

    The last error is occurring in your view because $customer does not contain an index of id. Inspect the response from $this->customer->get_customer($id) using var_dump() to find out why.

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

Sidebar

Related Questions

I have a simple crud application, and the edit page in my controller is
I have a simple application using the Play! framework's secure module. My 'Users' controller
I'm recently have learned to use Zend Framework. I did a simple CRUD application.
I have a simple Crud application where there is one filed called Category. During
I am working on my second CI application. I have created some simple CRUD
I have a simple mvc application which perform the CRUD functionality to manage UserDetials.
I have a fairly simple CRUD web application (C#/ASP.NET) that runs fine in Firefox,
I am a newbie trying to create a simple (in theory) CRUD application using
Have spent a week trying to wrap my head around Yii framework, but while
I have createa simple CRUD application utilize JPA and Hibernate. I have entity annotated

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.