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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:12:20+00:00 2026-06-14T15:12:20+00:00

I currently update my database records with an input like this $this->my_model->update($id, $this->input->post())); (This

  • 0

I currently update my database records with an input like this

$this->my_model->update($id, $this->input->post()));

(This is after I have performed a validation on all the input. The “model” also has a white_list of data to expect.)

Problem: if I am updating a checkbox, and it is “unticked” (i.e. ‘false’) – then that field is not ‘posted’ by the browser.

For example – if I tick checkbox_two – but leave checkbox_one unticked, $_POST shows:

[field_one] = "some value"
[field_two] = "some value"
[checkbox_two] = 1

Therefore my model will not update that field – since it is not part of the post.

The same does not happen in reverse – because a “ticked” checkbox is posted as “1” – and thus is correctly updated.

[field_one] = "some value"
[field_two] = "some value"
[checkbox_one] = 1
[checkbox_two] = 1

Question: Does anyone have an elegant solution to handle this, other than having to always specifically check for each checkbox?

  • 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-14T15:12:21+00:00Added an answer on June 14, 2026 at 3:12 pm
    <input type="hidden" name="example" value="FALSE" />
    <input type="checkbox" name="example" value="TRUE" />
    

    This practice is easy and logical. If checkbox is checked, $this->input->post('example') == 'TRUE' else, $this->input->post('example') == 'FALSE'.

    The latest given value of a name="" overrides previous, thus givin prio checkbox > hidden.

    EDIT: this solution is equal to given most rated answer in Rick Calder’s comment. I’ve also come to this conclusion on my own, though.

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

Sidebar

Related Questions

I currently have a problem attepting to update a record within my database. I
We currently have some php code that allows an end user to update records
I currently have a database that gets updated from a legacy application. I'd like
I'm currently attempting to update existing records within a MySQL database. Prior to the
currently in my update controller method I have: @group.attributes = { :title => params[:group][:title],
Currently I have to write the following to update an element already contained in
I currently have a list of things to update in the given mysqli query:
Currently, I am using an with ajax to update my mysql. Now, I have
I'm trying to update my database records with the following code but am having
I have a database filled with records in the following format: . What I

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.