Jump to content


PHP and radio buttons


1 reply to this topic

#1 baggyn

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Location:Top secret
  • Interests:COMPUTER

Posted 12 July 2005 - 11:09 AM

hi

im designing a web site and i need the PHP to echo certain text when a radio button is selected and for it to echo a differnet piece of text when another radio button is selected

can any one help???

#2 QuietWhistler

    Young Padawan

  • Members
  • Pip
  • 19 posts

Posted 13 July 2005 - 03:50 AM


<?php
if(isset($_POST['posted']))
{
if($_POST['question1'] == "Lisbon")
{
echo "You are correct, $_POST[question1] is the right answer.<hr>";
}

if($_POST['question1'] != "Lisbon")
{
echo "You are incorrect, $_POST[question1] is not the right answer.<hr>";
}
}
?>
<form method="post" action="quiz.php">
<input type="hidden" name="posted" value="true">
What is the capital of Portugal ?
<br>
<br>
<input name="question1" type="radio" value="Porto">
Porto
<br>
<input name="question1" type="radio" value="Lisbon">
Lisbon
<br>
<input name="question1" type="radio" value="Madrid">
Madrid
<br>
<br>
<input type="submit" value="Submit Question">


That should do the trick, ask if you want more help





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users