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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:29:13+00:00 2026-05-19T02:29:13+00:00

How can i get the names or id’s of the multiple selected checkboxes on

  • 0

How can i get the names or id’s of the multiple selected checkboxes on submit, using the PHP? Following is example form. Thanks.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
   <input type="checkbox" name="orange" id="orange">
   <input type="checkbox" name="apple" id="apple">
   <input type="checkbox" name="sky" id="sky">
   <input type="checkbox" name="sea" id="sea">
   <br>
   <br>
   <input type="submit" name="Submit" value="Submit">
</form>
  • 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-19T02:29:14+00:00Added an answer on May 19, 2026 at 2:29 am

    Checkbox values are submitted from a form only if the checkbox is selected. What’s more, it’s the name attribute that counts, not the ID.

    There are several ways of handling checkboxes in PHP:

    1. Give all checkboxes the same name followed by a pair of square brackets, so the entire set is treated as an array. In this case, give each checkbox a value.
    2. Give each checkbox a different name and a value.
    3. Give each checkbox a different name, but no value.

    In each case, you need to check for the existence of the checkbox name in the $_POST array.

    For example:

    <input type="checkbox" name="color[]" id="orange" value="orange">
    <input type="checkbox" name="color[]" id="apple" value="apple">
    

    To get the values for these checkboxes:

    if (isset($_POST['color'])) {
        $colors = $_POST['color'];
        // $colors is an array of selected values
    }
    

    However, if each checkbox has a different name and an explicit value like this:

    <input type="checkbox" name="orange" id="orange" value="orange">
    <input type="checkbox" name="apple" id="apple" value="apple">
    

    You still need to use isset():

    if (isset($_POST['orange'])) {
        // orange has been set and its value is "orange"
    }
    

    If you don’t set a value, the default value is “on”, but it won’t be in the $_POST array unless it has been selected, so you still need to use isset().

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

Sidebar

Related Questions

How can I get all columns' names from an Oracle table using Java? Is
Hey, I'm wondering how I can get the class names dynamically using jquery for
How can I get the field names of an MS Access database table? Is
How can I get a list of the IP addresses or host names from
How can I get all products from customers1 and customers2 include their customer names?
If I have a property: public list<String> names { get; set; } How can
Can we get variable name('PHPSESSID') defined php.ini through some function in PHP? I know
How can I get the name of a file in in PHP? What I
How i can get full right name of generic type? For example: This code
I want to get user names in active directory by using sharepoint webpart. any

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.