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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:57:15+00:00 2026-05-29T07:57:15+00:00

I have a PHP form with several check boxes (not groups) with different names

  • 0

I have a PHP form with several check boxes (not groups) with different names that when submitted get sent to an array and emailed. The problem I am having is that I am looking for a way to validate that at least one of the check boxes is checked upon submit. I know how to do one check box or to do check box groups but not this. How can this be done? If someone could point me in the right direction I would be grateful.

I am adding the code for the section of the form I am asking about.

  <form action="" method="post">



   <fieldset>
        <legend>
            Please Select at least one:
        </legend>
 <p class="style5">Type of Alleged Occurrence:<input name="occurrence" type="hidden"    value="<?php { print 'Type of Occurrence'; }?>"></p>
                            <font size="-1"   face="Arial, Helvetica, sans-serif" align="left">
                            <table style="width: 100%">
                                <tr><td   style="width: 21%; height: 57px;"><strong> Disruption:</strong><br><input name="obscene"   type="checkbox" value="Obscene Language" <?php if(isset($_POST['obscene'])) echo "checked"; ?>><label  id="obscene">Obscene language </label>
                                    </td><td   style="width: 33%; height: 57px;">
                                    <strong> Sexual Harassment:</strong><br><input name="sexharass" type="checkbox" value="Physical" <?php if(isset($_POST['sexharass'])) echo "checked"; ?>  ><label  id="sexharass">Physical </label>&nbsp;<span lang="en-us">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </span>&nbsp;<input name="sexharass" type="checkbox" value="Verbal" <?php if(isset($_POST['sexharass'])) echo "checked"; ?> ><label  id="sexharass2">Verbal </label>

<td  style="width: 21%; height: 57px;"><strong> Altercation:</strong>
<br><input name="altercation1" type="checkbox" value="Verbal" <?php if(isset($_POST['altercation1'])) echo "checked"; ?>><label id="Label3">Verbal</label>

 <input name="altercation1" type="checkbox" value="Physical" <?php   if(isset($_POST['altercation1'])) echo "checked"; ?> ><label id="Label4">Physical</label> <br>



                                    <td    style="width: 33%; height: 57px;"><strong>Involved in altercation:</strong><br>



 <input name="altercation2" type="checkbox" value="student/student" <?php if(isset($_POST['altercation2'])) echo "checked"; ?>><label id="Label3">Student/Student </label>


<input name="altercation2" type="checkbox" value="student/faculty-staff" <?php if(isset($_POST['altercation2'])) echo "checked"; ?>><label id="Label4">Student/Faculty-Staff </label>

<tr><td><strong> Theft/ Damage to Property:</strong><br><input name="property" type="checkbox" value="DACC" <?php if(isset($_POST['property'])) echo "checked"; ?>  ><label  id="property">DACC </label>&nbsp;<span lang="en-us">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size="-1" face="Arial, Helvetica, sans-serif" align="left"><input name="property1" type="checkbox" value="Self" <?php if(isset($_POST['property'])) echo "checked"; ?> ><label  id="property3">Self </label>



</font>&nbsp;&nbsp;<br>
                                    </span><input name="property" type="checkbox" value="Faculty/Staff" <?php if(isset($_POST['property'])) echo "checked"; ?> ><label  id="property2">Faculty/Staff </label>




  </td>
   <td><strong> Threat of Harm to Self or Others:</strong><br><input name="harm" type="checkbox" value="Student/Student" <?php if(isset($_POST['harm'])) echo "checked"; ?>  >
<label  id="harm">Student/Student </label>&nbsp;<span lang="en-us">&nbsp;&nbsp;&nbsp;<font size="-1" face="Arial, Helvetica, sans-serif" align="left"><input name="harm2" type="checkbox" value="Self" <?php if(isset($_POST['harm'])) echo "checked"; ?> ><label  id="property2">Self </label>



</font><br>
                                    </span>
            <font size="-1" face="Arial, Helvetica, sans-serif" align="left">
                            <span lang="en-us"><input name="harm1" type="checkbox" value="Student/Faculty-Staff" <?php if(isset($_POST['harm'])) echo "checked"; ?> ><label  id="harm3">Student/Faculty-Staff </label>



            &nbsp;&nbsp;</span></font></td></tr>


<tr><td><strong> Drugs/Alcohol:</strong><br><input name="drugs" type="checkbox" value="Under the Influence" <?php if(isset($_POST['drugs'])) echo "checked"; ?>  ><label  id="drugs">Under the Influence </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size="-1" face="Arial, Helvetica, sans-serif" align="left"><input name="drugs" type="checkbox" value="Possession" <?php if(isset($_POST['drugs'])) echo "checked"; ?> ><label  id="drugs2">Possession </label>



</font>




   </td><td><strong> Other Occurrences:</strong><br><input name="other" type="checkbox" value="Student/Student" <?php if(isset($_POST['other'])) echo "checked"; ?>  ><label  id="other">Trespassing </label>&nbsp;<span lang="en-us">&nbsp;&nbsp;&nbsp;<font size="-1" face="Arial, Helvetica, sans-serif" align="left"><input name="other" type="checkbox" value="Other" <?php if(isset($_POST['other'])) echo "checked"; ?> ><label  id="other2">Other </label>



</font><br>
                                    </span>
            </td></tr>              </table><p></p>
  • 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-29T07:57:15+00:00Added an answer on May 29, 2026 at 7:57 am

    Depending on your form structure, you’re going to need to use the isset() check. Assuming you’re NOT posting as an array (<input type='checkbox' name='cb[]' value='x' /><input type='checkbox' name='cb[]' value='x' />...etc, you can do it this way:

    <form method='post'...>
    <input type='checkbox' name='cb1' value='x' />
    <input type='checkbox' name='cb2' value='x' />
    </form>
    

    validate with…

    $require_one_of = array('cb1','cb2',...etc); //names of posted checkboxes
    $one_set=false;
    foreach($require_one_of as $key){
       if(isset($_POST[$key])){
          $one_set=true;
          break;
       }
    }
    if(!$one_set){
       //error handling
    }
    

    If you are posting as an array, then you can just check if the array is set:

    <form method='post'...>
    <input type='checkbox' name='cb[]' value='x' />
    <input type='checkbox' name='cb[]' value='x' />
    </form>
    

    validate with

    <?php
     if(!isset($_POST['cb'])){
       //error handling
    }
    ?>
    

    Note: I’m assuming here that you’re using post as for form submission method

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

Sidebar

Related Questions

I have a php file that contains a form (which contains 2 input boxes
I have a php form that has a known number of columns (ex. top
I currently have a PHP form that uses AJAX to connect to MySQL and
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
I have a PHP page that queries a DB to populate a form for
I have a form (signup.php) that pops up in a nyroModal window when I
For example, I have a HTML form with several input buttons, <form action=/index.php method=post>
I have a form with several inputs that deal with files. The javascript validation
I have a form which have five buttons and several checkboxes holding different values.
I have coded a php script that is used to check the status of

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.