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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:39:36+00:00 2026-05-13T16:39:36+00:00

i have an html form full of text fields, checkbox’s , and radio fields.

  • 0

i have an html form full of text fields, checkbox’s , and radio fields.
i wanted to get all the names of the fields so that i can get started in validating the information in them.

the method i am using to get them is

if(isset($_POST['submit'])) {
    foreach($_POST as $name => $value) {
    print $name."<br/>";
    }
}

but i noticed that it only displays textbox and textarea field names and it doesnt include checkbox and radio field names through this submission. do i need to include anything for it to grab the field names of those?

  • 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-13T16:39:36+00:00Added an answer on May 13, 2026 at 4:39 pm

    Checkboxes and radio buttons work a little differently than your standard inputs. If a checkbox is present on a form that doesn’t necessarily mean that it will be available in the resulting POST information. Rather, those values will only be avialable if they are actually marked (checkboxes checked and radio buttons selected). The proper way to test for their value in PHP is not to check the field value but rather to check isset() first.

    For a checkbox:

    $data['my_checkbox'] = isset($_POST['my_checkbox']) ? 'on' : 'off';
    

    and for a radio button:

    $data['my_radio'] = isset($_POST['my_radio']) ? $_POST['my_radio'] : false;
    

    To be a little more descriptive let’s say you have the following form:

    <form action="test.php" method="post">
      <input type="text" name="email" value="" />
      <input type="checkbox" name="active" value="Yes" />
      <input type="submit" value="Submit" />
    </form>
    

    If I were to submit that form with an email value of ‘test@email.com’ but not check the checkbox I would have the following in $_POST:

    Array (
      'email' => 'test@email.com'
    )
    

    However, if I were to submit the same form with the same email address and check the checkbox I would have the following:

    Array (
      'email' => 'test@email.com',
      'active' => 'Yes'
    )
    

    Hope that helps.

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

Sidebar

Related Questions

I have a HTML form that has certain fields which i am opening inside
I have an html form and some jQuery that validates the form. If all
I have a following problem, I have HTML form that uploads a file with
I have a HTML form that accepts a comma separated list of tags, which
I have a html form <form action=process.php method=post> <input type=checkbox name=name[v1] /> <input type=checkbox
I have a form that I copied over from new.html.erb and put it in
Here i have HTML: <form id=referalForm action=google.com> <label>Referring patient:</label> <input type=text ame=txtPname id=fullname placeholder=ENTER
i have html form i am using <a href="#" onclick="document.aa.submit()"> instead of submit button
My input tag started to go crazy... I have html form for input to
I have an html form and I need to populate one of the input

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.