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

The Archive Base Latest Questions

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

My form has both a text area and check boxes. When I POST the

  • 0

My form has both a text area and check boxes. When I POST the results, only one of the check box values gets posted, even if more than one is selected.

This is my form:

<form action="search.php">
<input type="text" name="term">

<input type="checkbox" name="filter" value="subject"> Subject
<input type="checkbox" name="filter" value="course"> Course
<input type="checkbox" name="filter" value="professor"> Professor

<input type="submit" name="submit" value="Go" />

And this is how I echo the form (search.php):

<?php
$term = $_GET['term'];
$filter = $_GET['filter'];
echo "$term $filter";
?>
  • 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-25T11:06:26+00:00Added an answer on May 25, 2026 at 11:06 am

    The trouble is the names you have assigned each checkbox, what is happening currently is the first checkbox is being read by the PHP and its value assigned to the variable, the next filter checkbox is being read but then overwriting the currently assigned value of the variable, and then again with the 3rd checkbox. So you’ll always only ever get the last ticked checkbox as your value for the $filter variable.

    You need to individually assigned each checkbox with a different name for example:

    <form action="search.php">
    <input type="text" name="term" />
    
    <input type="checkbox" name="filter1" value="subject" /> Subject
    <input type="checkbox" name="filter2" value="course" /> Course
    <input type="checkbox" name="filter3" value="professor" /> Professor
    
    <input type="submit" name="submit" value="Go" />
    

    Then the PHP:

    <?php
    $term = $_GET['term'];
    $filter1 = $_GET['filter1'];
    $filter2 = $_GET['filter2'];
    $filter3 = $_GET['filter3'];
    echo "$term $filter1 $filter2 $filter3";
    ?>
    

    You also had your last checkbox’s value the same as the second so I changed the value from course to professor, if this is in fact wrong, you can obviously change it back.

    Another note, it may also be a good idea to use the method POST instead of GET as it’s more secure, however, you may have reasons to be using GET, but it’s just a heads up 🙂

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

Sidebar

Related Questions

I created a contact form with a text area input only field, which allows
I have a winforms app and the main (and only) form has several buttons.
I have a html page with a form. The form has Div which gets
Let say my form has 2 inputs <input name=person_name value=John type=text /> <input name=person_name
Suppose if my form has button and label and Button1 has Text Property’s Text
I have created a dialog box in my WinForms application. This has many text
Form has the DoubleBuffered property (bool, inherited from Control). If this is set to
My form has a custom element like below, created using custom ajax: <select jwcid=testtest
My form has several numeric up down controls. All of these controls, when changed,
If a form has same tag repeatedly, how to get its value in JavaScript?

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.