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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:06:12+00:00 2026-05-25T02:06:12+00:00

PHP: if (isset($_POST[‘checkbox’])){ foreach ($_POST[‘checkbox’] as $x){ array_push($arr, judgeNametoID($x)); } } I’ve been getting

  • 0

PHP:

if (isset($_POST['checkbox'])){
    foreach ($_POST['checkbox'] as $x){
        array_push($arr, judgeNametoID($x));
    }
}

I’ve been getting errors when there’s only one checkbox selected. If I keep the isset() in there, I don’t get errors, only the checkbox selected is not added to the array.

Why is $_POST[‘checkbox’] not getting set if there’s only one checkbox selected?

PHP/HTML of page with the checkboxes:

echo '<ul>';
            $list = getActiveJudges();
            foreach ($list as $x){
                $found = 0;
                    foreach ($arr as $y){
                        if ($x == $y){
                            $found = 1;
                            break;
                        }
                    }
                    if ($found==1){
                        echo '<li>';
                        array_push($selectedJudges, judgeNametoID($x));
                        echo '<input type="checkbox" checked="checked" name="checkbox[]" value="'.$x.'" />'.$x.'<br/>';
                        echo '</li>';   
                    }
                    else {
                        echo '<li>';
                        echo '<input type="checkbox" named="unchecked[]" value="'.$x.'" />'.$x.'<br/>';
                        echo '</li>'; 
                    }
            }
                echo '</ul>';

Errors when I remove the isset():

Notice: Undefined index: checkbox in c:\Inetpub\wwwroot\CaseManagement\changeuserjudgeprocess.php on line 11

Warning: Invalid argument supplied for foreach() in c:\Inetpub\wwwroot\CaseManagement\changeuserjudgeprocess.php on line 14

  • 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-25T02:06:13+00:00Added an answer on May 25, 2026 at 2:06 am

    Is the input name actually checkbox?
    If you want to iterate through a list of checkboxes, you’ll need html like this

    <input type="checkbox" name="checkbox[]">
    <input type="checkbox" name="checkbox[]">
    <input type="checkbox" name="checkbox[]">
    

    But that doesn’t help very much as you won’t know which checkbox was checked, so you could try something like

    <input type="checkbox" name="checkbox[checkbox1]">
    <input type="checkbox" name="checkbox[checkbox2]">
    <input type="checkbox" name="checkbox[checkbox3]">
    

    and then loop through like so:

    if(isset($_POST['checkbox'])){
        foreach($_POST['checkbox'] as $checkboxID => $checkboxVal){
             // $checkboxID will be checkbox1, checkbox2, checkbox3 as specified above.
             // $checkboxVal will always be 'on'
        }
    }
    

    Of course, you may already have html like this, if so, we’ll need to see it in order to help more 🙂

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

Sidebar

Related Questions

<input type=checkbox class=christmasCheckBox name=additionalDonationCheckbox value=yes id=additionalDonationCheckbox <?php echo (isset($_POST['additionalDonationCheckbox'])&&($_POST['additionalDonationCheckbox']!='')) ? 'checked=checked' : ''; ?>
Take this code: <?php if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; } if
<?php session_start(); include(connect.php); $timeout = 60 * 30; $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); if(isset($_POST['userName']))
My email code isn't working. <?php if(isset($_POST['send'])){ $to = info@erbimages.com ; // change all
I have the following code: <select name=to class=combo value=' <?php if(isset($_POST['reply'])) { echo <option
I can't seem to validate file upload fields, here's my code: <?php if (isset($_POST['submit']))
<?php if (isset($_POST['first']) && isset($_POST['second']) && isset($_POST['submit']) && $_POST['DDL'] == "+") { $equals =
I currently have: <?php if (isset($_POST[submitwrite])) { $handle = fopen(writetest.txt,w+); if ($handle) { fwrite($handle,
I have two pages apply.php and registration.php. In registration.php , i have if(isset($_POST['submitted'])){ //validation
For example i use this little code: <?php if (isset($_POST['Submit'])){ if ((@$_POST['Submit'] == 'x'))

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.