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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:52:50+00:00 2026-06-02T22:52:50+00:00

how do I insert the data for a radio button a user selects?

  • 0

how do I insert the data for a radio button a user selects?

  • 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-02T22:52:51+00:00Added an answer on June 2, 2026 at 10:52 pm

    Your question is not 100% clear to me, do you wanna know how to save a radio button input to a database or how to setup something where a user clicks a radiobutton and based on the selection he must fill out a form?

    Assuming your HTML for your radio button is like this:

    <input type="radio" name="choice" value="1"> Choice 1
    <input type="radio" name="choice" value="2"> Choice 2
    

    You can save that to your database by:

    mysql_query("INSERT INTO TABLE (choice) VALUES ('".mysql_real_escape_string($_POST['choice'])."')") or die(mysql_error());
    

    If you submit different fields based on the radiobutton that is selected you can just use:

    if ($_POST['choice'] == 1) {
     // Do something with the input fields connected to choice1
    } else {
    // Do something with the input fields connected to choice2 (Assuming you only use 2 radio selects)
    }
    

    EDIT //

    Based on your HTML FORM you can use the code below to insert the values into your database:

    if (isset ($_POST['Submit'])) {
    
        if (empty ($_POST['CID'])) {
    
            echo 'You must fill out your Course ID, <a href="javascript:history.back(1)">Go back</a>.';
    
        } elseif (empty ($_POST['Time'])) {
    
            echo 'You must fill out the Time field, <a href="javascript:history.back(1)">Go back</a>.';
    
        } else {
    
            // Insert into mysql database
            mysql_query("INSERT INTO TABLE (CID, Time) VALUES ('".mysql_real_escape_string($_POST['CID'])."', '".mysql_real_escape_string($_POST['Time'])."')") or die (mysql_error());
    
            echo 'Thank you, your request has been submitted.';
        }
    
    } else {
    
        echo 'Error : No Submit action has been placed.';
    
    }
    
    ?>
    

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

Sidebar

Related Questions

I want to insert data into SQL Server database when I click Insert button
Assuming this that we in time insert data in database has 3 input:radio and
Hi need insert data in table if the record is not already exits Ex:
How i insert data into xml file using Windows Application in .net?
I am trying to insert data about an item's price from an HTML form
I want to insert data into a table where I don't know the next
I need to insert data from table1 into table2. However, I would like to
I want to insert data into the postgresql database of OpenERP, I am able
I am trying to insert data in table, but if it already exists in
I'm trying to insert data into the SQLite database using get EditText, but I

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.