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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:57:41+00:00 2026-06-14T20:57:41+00:00

There are 3(I do not know how many would be it changeable. 3 only

  • 0

There are 3(I do not know how many would be it changeable. 3 only example) checkboxes in my form and I want to detect unchecked checkboxes with php when it post. How can I do this?

  • 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-14T20:57:42+00:00Added an answer on June 14, 2026 at 8:57 pm

    Gumbo is right. There is a work around however, and that is the following:

    <form action="" method="post">
        <input type="hidden" name="checkbox" value="0">
        <input type="checkbox" name="checkbox" value="1">
        <input type="submit">
    </form>
    

    In other words: have a hidden field with the same name as the checkbox and a value that represents the unchecked state, 0 for instance. It is, however, important to have the hidden field precede the checkbox in the form. Otherwise the hidden field’s value will override the checkbox value when posted to the backend, if the checkbox was checked.

    Another way to keep track of this is to have a list of possible checkboxes in the back-end (and even populate the form in the back-end with that list, for instance). Something like the following should give you an idea:

    <?php
    
    $checkboxes = array(
        array( 'label' => 'checkbox 1 label', 'unchecked' => '0', 'checked' => '1' ),
        array( 'label' => 'checkbox 2 label', 'unchecked' => '0', 'checked' => '1' ),
        array( 'label' => 'checkbox 3 label', 'unchecked' => '0', 'checked' => '1' )
    );
    
    if( strtolower( $_SERVER[ 'REQUEST_METHOD' ] ) == 'post' )
    {
        foreach( $checkboxes as $key => $checkbox )
        {
            if( isset( $_POST[ 'checkbox' ][ $key ] ) && $_POST[ 'checkbox' ][ $key ] == $checkbox[ 'checked' ] )
            {
                echo $checkbox[ 'label' ] . ' is checked, so we use value: ' . $checkbox[ 'checked' ] . '<br>';
            }
            else
            {
                echo $checkbox[ 'label' ] . ' is not checked, so we use value: ' . $checkbox[ 'unchecked' ] . '<br>';
            }
        }
    }
    ?>
    <html>
    <body>
    <form action="" method="post">
        <?php foreach( $checkboxes as $key => $checkbox ): ?>
        <label><input type="checkbox" name="checkbox[<?php echo $key; ?>]" value="<?php echo $checkbox[ 'checked' ]; ?>"><?php echo $checkbox[ 'label' ]; ?></label><br>
        <?php endforeach; ?>
        <input type="submit">
    </form>
    </body>
    </html>
    

    … check one or two checkboxes, then click the submit button and see what happens.

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

Sidebar

Related Questions

I know this is not the only question out there, but I still couldn't
I do not know why there are 2 matches found aside from the input
I know from reading the assoc. Google group that there is not currently an
Does anyone know there have any other way that (by not using json_encode and
I know there is a lot of controversy (maybe not controversy, but arguments at
Is there any way to know in Servlet is JS is enable or not
Is there a way in JSP to know the current page name (not the
I'm not too good with SQL and I know there's probably a much more
I know there is one, but it's not easy to implement the way I
Does anyone know if there is a google goggles API for Android? If not,

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.