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???
PHP and radio buttons
Started by baggyn, Jul 12 2005 11:09 AM
1 reply to this topic
#1
Posted 12 July 2005 - 11:09 AM
#2
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
