I got problems with radio inputs and PHP. I make a quiz and I set 4 optional answers each question. To make inputs not multi select able I gotta set their names the same. Unfortunately, PHP reads them by names and it makes PHP fail. How can I avoid it? I set optional number 1-4 for each answer. My example website and code: http://tourney.adrenalinex.co.uk/max-o-meter/index.php
[php]<?php
$q1_a1 = $_POST[‘q1_a1’];
$q1_a2 = $_POST[‘q1_a2’];
$q1_a3 = $_POST[‘q1_a3’];
$q1_a4 = $_POST[‘q1_a4’];
$score = 0;
if ($selected_radio = $q1_a1) {
$score = $score+4;
} else if ($selected_radio = $q1_a2) {
$score = $score+3;
} else if ($selected_radio = $q1_a3) {
$score = $score+2;
} else if ($selected_radio = $q1_a4) {
$score = $score+1;
}
echo $score;
?>[/php]
[code]
-
Question number one:
Answer 1
Answer 2
Answer 3
Answer 4