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

  • Home
  • SEARCH
  • 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 8244089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:43:51+00:00 2026-06-07T21:43:51+00:00

I would like to have several radio button to display information for a dynamic

  • 0

I would like to have several radio button to display information for a dynamic webpage. I have (in PHP):

echo '
    <html>
        <head>
            <title> Dynamic PHP </title>
        </head>
        <body>
            <form action="dynamic.php" method="get">
                <input type="radio" name="dynamic" value="home" checked> Home </br>
                <input type="radio" name="dynamic" value="site1"> Site 1 </br>
                <input type="radio" name="dynamic" value="site2"> Site 2
            </form>

        </body>
    </html>
';

if (isset($_GET["home"])){
    echo "Home";
}
if (isset($_GET["site1"])){
    echo "Site 1";
}
if (isset($_GET["site2"])){
    echo "Site 2";
}

I don’t get any errors, but nothing happens either. Thanks a lot.

Edit: This is like what I’m asking: radio button value in php

  • 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-07T21:43:53+00:00Added an answer on June 7, 2026 at 9:43 pm

    PHP accesses form variables through their “name” attribute, not their “value” attribute. In order to retrieve the value of the selected radio button, you would use $_GET['dynamic'] and not $_GET['home'] or $_GET['site1'] or $_GET['site2'].

    So assuming this page is called dynamic.php, your code to echo the selected one would be:

    if(!empty($_GET['dynamic'])){
    
        echo $_GET['dynamic'];
    
    }
    

    Hope this helps!

    EDIT: In order to echo the selected option:

    <?php 
    if(!empty($_GET['dynamic'])){
          $selected = $_GET['dynamic'];
    }
    else{
          //if no option was selected, set home as default
          $selected = 'home';
    }
    ?>
    
    <form action="dynamic.php" method="get">
             <input type="radio" name="dynamic" value="home"  /> Home <?php echo ($selected == 'home' ? 'This was selected!' : '');?> </br>
             <input type="radio" name="dynamic" value="site1" /> Site 1 <?php echo ($selected == 'site1' ? 'This was selected!' : '');?> </br>
             <input type="radio" name="dynamic" value="site2" /> Site 2 <?php echo ($selected == 'site2' ? 'This was selected!' : '');?> </br>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several UITableViews and what I would like to do is to be
I have several PDF templates that I would like to load and modify and
I have several columns in a MySQL database that I would like to add
I have several ASP.NET sites in IIS7 and would like to be able to
If I have several plots in a single panel, I would like to be
I have several python.exe processes running on my Vista machine and I would like
I have several file with the following format: lat,lon,value. I would like to plot
I have several classes with static const data members. I would like to know
I have several windows machines identified by ip address. I would like to write
I have several constant defined for a webservice, and I would like to make

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.