私はPHPにまったく慣れておらず、現在調査を行っています。ユーザーは、ラジオ ボタンでフォームの質問に対する回答を選択します。各質問には 4 つの可能性があり、各質問の下にグループ化されています。フォームが送信されると、各グループのどのボタンが選択されたかがページに表示されます。現時点でのコードは次のとおりです。
<form action="thankyou.php" method="post">
<p>How easy would you say it is to create new carers?</p>
<input type="radio" name="rgroup1" value="rg1v1"> Excellent
<input type="radio" name="rgroup1" value="rg1v2"> Good
<input type="radio" name="rgroup1" value="rg1v3"> Average
<input type="radio" name="rgroup1" value="rg1v4"> Poor</br>
<p>How easy is it to generate a report?</p>
<input type="radio" name="rgroup2" value="rg2v1"> Excellent
<input type="radio" name="rgroup2" value="rg2v2"> Good
<input type="radio" name="rgroup2" value="rg2v3"> Average
<input type="radio" name="rgroup2" value="rg2v4"> Poor</br>
<p>How easy is it to add and alter timesheets?</p>
<input type="radio" name="rgroup3" value="excellent"> Excellent
<input type="radio" name="rgroup3" value="good"> Good
<input type="radio" name="rgroup3" value="average"> Average
<input type="radio" name="rgroup3" value="poor"> Poor</br>
<p>How good would you rate the Packages Of Care functions? </p>
<input type="radio" name="rgroup4" value="excellent"> Excellent
<input type="radio" name="rgroup4" value="good"> Good
<input type="radio" name="rgroup4" value="average"> Average
<input type="radio" name="rgroup4" value="poor"> Poor</br>
<p>Question 5</p>
<input type="radio" name="rgroup5" value="excellent"> Excellent
<input type="radio" name="rgroup5" value="good"> Good
<input type="radio" name="rgroup5" value="average"> Average
<input type="radio" name="rgroup5" value="poor"> Poor</br>
</br>
Please Enter Your Comments Below:
</br></br>
<textarea name="comments" width="100px" rows="4" cols="50" wrap="wrap"></textarea>
</br></br>
<input type="submit">
<br/><br/>
</form>
「thankyou.php」ページの私のPHPは次のとおりです。
<?php
switch($_POST['rgroup1']) {
case "rg1v1":
$value = "Radio Group 1 - Value 1 was selected.";
break;
case "rg1v2":
$value = "Radio Group 1 - Value 2 was selected.";
break;
case "rg1v3":
$value = "Radio Group 1 - Value 3 was selected.";
break;
case "rg1v4":
$value = "Radio Group 1 - Value 4 was selected.";
break;
default:
$value = "No radio has been selected for Radio Group 1";
}
switch($_POST['rgroup2']) {
case "rg2v1":
$value2 = "Radio Group 2 - Value 1 was selected.";
break;
case "rg2v2":
$value2 = "Radio Group 2 - Value 2 was selected.";
break;
case "rg2v3":
$value2 = "Radio Group 2 - Value 3 was selected.";
break;
case "rg2v4":
$value2 = "Radio Group 2 - Value 4 was selected.";
break;
default:
$value = "No radio has been selected for Radio Group 2";
}
switch($_POST['rgroup3']) {
case "rg3v1":
$value3 = "Radio Group 3 - Value 1 was selected.";
break;
case "rg3v2":
$value3 = "Radio Group 3 - Value 2 was selected.";
break;
case "rg3v3":
$value3 = "Radio Group 3 - Value 3 was selected.";
break;
case "rg3v4":
$value3 = "Radio Group 3 - Value 4 was selected.";
break;
default:
$value = "No radio has been selected for Radio Group 3";
}
switch($_POST['rgroup4']) {
case "rg4v1":
$value4 = "Radio Group 4 - Value 1 was selected.";
break;
case "rg4v2":
$value4 = "Radio Group 4 - Value 2 was selected.";
break;
case "rg4v3":
$value4 = "Radio Group 4 - Value 3 was selected.";
break;
case "rg4v4":
$value4 = "Radio Group 4 - Value 4 was selected.";
break;
default:
$value = "No radio has been selected for Radio Group 4";
}
switch($_POST['rgroup5']) {
case "rg5v1":
$value5 = "Radio Group 5 - Value 1 was selected.";
break;
case "rg5v2":
$value5 = "Radio Group 5 - Value 2 was selected.";
break;
case "rg5v3":
$value5 = "Radio Group 5 - Value 3 was selected.";
break;
case "rg5v4":
$value5 = "Radio Group 5 - Value 4 was selected.";
break;
default:
$value = "No radio has been selected for Radio Group 5";
}
echo $value;
echo $value2;
echo $value3;
echo $value4;
echo $value5;
?>
value2、3、4、および 5 の変数を定義していないというエラーが表示されますが、その理由がわかりません。