How to echo a radio button?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aronjeney
Forum Newbie
Posts: 4
Joined: Tue Sep 08, 2009 6:59 pm

How to echo a radio button?

Post by aronjeney »

I am a designer and ultimate newbie to php so all help is VERY appreciated. I am slowly teaching myself fundamentals.

I have a client who is accepting donations through paypal and would like to have a radio button appear on the Thank You page IF a user donates more than $30. I have gotten so far as to ECHO a set of text if they donate more than $30, but am having troubles ECHOing a form for a clickable radio button. Can I echo a form or do I incorporate the php into a form?

Here is the code that I am attempting:

Code: Select all

 
 
     <?php       
            if ($_POST['amt'] >= 30) {
            echo '<Form name ="form1" Method ="Post" ACTION ="radioButton.php">
              <Input type = 'Radio' Name ='sendreport' value= 'true'>
              <span>Check this box if you would like to receive email forecasts directly from the Colorado Avalanche Information Center.</span>
              <Input type = "Submit" Name = "Submit1" Value = "Get weather reports">
            </FORM> ';
            } else {
            echo 'Thank you.';
            }
      ?>
 
 

Thank you so much in advance for any help/suggestions!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: How to echo a radio button?

Post by Christopher »

The value will be in $_POST['sendreport'].
(#10850)
aronjeney
Forum Newbie
Posts: 4
Joined: Tue Sep 08, 2009 6:59 pm

Re: How to echo a radio button?

Post by aronjeney »

I was able to solve my issue by simply single quoting within the quotes..

Code: Select all

<?php       
            if ($_POST['amt'] >= 29) {
            echo "<Form name ='form1' Method ='Post' ACTION =''>
                    <Input type = 'Radio' Name ='sendreport' value= 'true'>
                    <span>Check this box if you would like to receive email forecasts directly from the Colorado Avalanche Information Center.</span>
                    <Input type = 'Submit' Name = 'Submit1' Value = 'Get weather reports'>
                  </FORM> ";
                  } else {
                  echo 'Thank you.';
                  }
                  ?>
                </div>

Thanks all!
Post Reply