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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:14:21+00:00 2026-06-07T20:14:21+00:00

I had a PHP processing script for an HTML form that had been working

  • 0

I had a PHP processing script for an HTML form that had been working in the past. We had used the form extensively and everything was getting into the DB just fine. Now I’m using it again (on the same page, it had just been inactive till now) and I’m running into some trouble with my checkboxes processing.

I’ve been toying with it to try and see where I’m messing up and I’ve gathered that I must be mistakenly processing the checkboxes in PHP. This is what I have currently:

HTML:

<label for="race" style="padding-right: 15px;">Race:</label>
    White <input type="checkbox" name="raceWhite" value="White" />
    Black <input type="checkbox" name="raceBlack" value="Black" />
    Asian/Pacific Islander <input type="checkbox" name="raceAsian" value="Asian/Pacific Islander" />
    Hispanic/Latino <input type="checkbox" name="raceHispanic" value="Hispanic/Latino" />
    Other <input type="checkbox" id="race" name="raceOther" value="Other" />

And here’s my PHP:

if (isset($_POST['raceWhite']))
    $white = true;
else echo "wtf is going on";
if (isset($_POST['raceBlack']))
    $black = true;
if (isset($_POST['raceAsian']))
    $asian = true;
if (isset($_POST['raceHispanic']))
    $hispanic = true;
if (isset($_POST['raceOther']))
    $otherRace = true;

I’m concerned because I’m echoing out “wtf is going on” and if I am understanding correctly, that is because the checkbox for raceWhite is not checked when I am indeed checking it as I test this. Also, with this method, my DB reflects these as being NULL — i.e. the checkboxes were not checked.

However, with my old code, the DB flips all the values to 1 which is represents all the checkboxes being checked. My old code went like this:

HTML:

<label for="race" style="padding-right: 15px;">Race:</label>
    White <input type="checkbox" name="race[]" value="White" />
    Black <input type="checkbox" name="race[]" value="Black" />
    Asian/Pacific Islander <input type="checkbox" name="race[]" value="Asian/Pacific Islander" />
    Hispanic/Latino <input type="checkbox" name="race[]" value="Hispanic/Latino" />
    Other <input type="checkbox" id="race" name="race[]" value="Other" />

PHP:

$raceList = $_POST["race"];
$n = count($raceList);
for($i = 0; $i < $n; $i++){
    switch($raceList[$i]){
        case "White":
            $white = 1;
        case "Black":
            $black = 1;
        case "Asian/Pacific Islander":
            $asian = 1;
        case "Hispanic/Latino":
            $hispanic = 1;
        case "Other":
            $otherRace = 1;
    }
}

Any help would be greatly appreciated. I’m sure I’m just missing something simple. This is my first time asking a question here so if I left out anything I should include in the future, please let me know.

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

    You can write is as

    $white = (isset($_POST['raceWhite']) && $_POST['raceWhite']=='White') ? 1 : 0;
    $black = (isset($_POST['raceBlack']) && $_POST['raceBlack']=='Black') ? 1 : 0;
    $asian = (isset($_POST['raceAsian']) && $_POST['raceAsian']=='Asian/Pacific Islander') ? 1 : 0;
    $hispanic = (isset($_POST['raceHispanic']) && $_POST['raceHispanic']=='Hispanic/Latino') ? 1 : 0;
    $otherRace = (isset($_POST['raceOther']) && $_POST['raceOther']=='Other') ? 1 : 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working with PHP sessions, and everything is working fine it does exactly
I have a php script that does some processing (creates remittance advice PDFs, self-billing
I had a working relationship with a Java server and a PHP server using
I have a php script that only produces logs to the client. When I
I am using a PHP Sign-Up script provided by PHP Form Generator . There
I'm a PHP dev and I'm new to Rails but have been getting on
So I've just installed XAMPP today, and I noticed that the index.php had a
I have a php curl script that uses 10 MB per running session. I'd
If I had PHP code in the database, could I include that somehow in
I've had something strange happen lately with php script I use to send emails

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.