Hello. Below Iv made a script wich asks 3 questions,
and if all 3 are correct it should sum up one point
for each correct answer. But it doesnt work.
I only get one correct answer at the end.
Would greatly apreciat help on this.
Here is my script :
<?php
$woman = array('Anette Sagen','Line Jahr','Henriette Lien');
$w = $_POST['w'];
$men = array('Matti Nykanen','Sven Hannawald','Bjørn Wirkola');
$m = $_POST['m'];
$land = array('Norway','Finland','Germany');
$l = $_POST['l'];
if (empty($_POST)) {
echo "Who won the womans jump week in 2004 ?";
echo "<form method=post action=$_SERVER[PHP_SELF]>";
foreach($woman as $w) {
echo "<input type=radio name=w value='$w'>$w<br>";
}
echo "<input type=submit value=Answer>";
echo "</form>";
}
elseif($w==$woman[1] or $w==$woman[2]) {
echo "$w is wrong answer.<br>";
echo "<a href=$_SERVER[PHP_SELF]>Try again</a>";
}
elseif($w==$woman[0]) {
echo "$w is correct.<br>";
echo "Who is the king of the jumpweek ?";
echo "<form method=post action=$_SERVER[PHP_SELF]>";
foreach($men as $m) {
echo "<input type=radio name=m value='$m'>$m<br>";
}
echo "<input type=submit value=Answer>";
echo "</form>";
}
elseif($m==$men[0] or $m==$men[1]) {
echo "$m is the wrong answer.<br>";
echo "<a href=$_SERVER[PHP_SELF]>Try again</a>";
}
elseif($m==$men[2]) {
echo "$m is correct.<br>";
echo "Wich country has most victories ?";
echo "<form method=post action=$_SERVER[PHP_SELF]>";
foreach($land as $l) {
echo "<input type=radio name=l value='$l'>$l<br>";
}
echo "<input type=submit value=Answer>";
echo "</form>";
}
elseif($l==$land[0] or $l==$land[2]) {
echo "$l is the wrong answer.<br>";
echo "<a href=$_SERVER[PHP_SELF]>Try again</a>";
}
else {
echo "$l is correct.<br>";
$result = ($l + $m + $w);
echo "You have ".count($result)." points!<br>";
echo "<a href=$_SERVER[PHP_SELF]>Try again</a><br>";
}
?>