【发布时间】:2019-09-05 15:02:10
【问题描述】:
我只使用 php 创建了一个简单的测验程序,并且有 4 个不同的问题和单选按钮,当我单击任何选项然后打印单选按钮的值,如 A 或 B 或 C 或 D 我创建了 4 个 php 变量,分配$_POST 方法的值,我想通过 echo 打印这些值。但是没有打印出来请帮助..
1. <style type="text/css"> body { background-color: grey; }
#computer , #politics { cursor: pointer; background:
linear-gradient(to right,blue,#bfbfe0); color: #fff; padding:
0px 0px 0px 5px; border-radius: 5px; width: 100%; }
.computer_qsnans , .politics_qsnans { display: ; }
</style> </head> <body>
<div class="main"> <form method="GET" action="index.php"> <div
id="computer"> <p>
<h1>
Technology
</h1> </p> </div>
<!-- Tecnical --> <div class="computer_qsnans"> <p>
<h4>
1.What is the full form of HTML
<div>
<input type="radio" name="tech_question_1" id="" value="A">
A) High Transparent Markup Laoyality
<input type="radio" name="tech_question_1" id="" value="B">
B) Hyper Text Markup Language
<input type="radio" name="tech_question_1" id="" value="C">
C) Hyper Text Mechanical Language
<input type="radio" name="tech_question_1" id="" value="D">
D) Hidro Terminate Markup Language
</div>
</h4> </p>
<p>
<h4>
2.What is upcoming android version
<div>
<input type="radio" name="tech_question_2" id="" value="A">
A) Pie
<input type="radio" name="tech_question_2" id="" value="B">
B) N
<input type="radio" name="tech_question_2" id="" value="C">
C) L
<input type="radio" name="tech_question_2" id="" value="D">
D) Q
</div>
</h4> </p> </div> <!-- Political -->
<div id="politics"> <p>
<h1>
Political
</h1> </p> </div>
<div class="politics_qsnans"> <p>
<h4>
1.The present Lok Sabha is the
<div>
<input type="radio" name="poli_question_1" id="" value="A">
A) 14th Lok Sabha
<input type="radio" name="poli_question_1" id="" value="B">
B) 15th Lok Sabha
<input type="radio" name="poli_question_1" id="" value="C">
C) 16th Lok Sabha
<input type="radio" name="poli_question_1" id="" value="D">
D) 17th Lok Sabha
</div>
</h4> </p>
<p>
<h4>
2.The minimum age to qualify for election to the Lok Sabha is
<div>
<input type="radio" name="poli_question_2" id="" value="A">
A) 25 years
<input type="radio" name="poli_question_2" id="" value="B">
B) 21 years
<input type="radio" name="poli_question_2" id="" value="C">
C) 18 years
<input type="radio" name="poli_question_2" id="" value="D">
D) 35 years
</div>
</h4> </p> </div>
<input type="submit" name="Submit" name="sbt" id="sbmt"> </form> </div><!--Main div end-->
</body> </html>
<?php if(isset($_GET['sbt'])) {
$answer1_for_qsn1 = $_GET['tech_question_1']; $answer2_for_qsn2 =
$_GET ['tech_question_2']; $answer3_for_qsn3 = $_GET
['poli_question_1']; $answer4_for_qsn4 = $_GET ['poli_question_2'];
echo $answer1_for_qsn1 ; echo $answer2_for_qsn2 ; echo
$answer3_for_qsn3 ; echo $answer4_for_qsn4 ;
}
?>
【问题讨论】: