里面我想知道如果你能帮助我与我的PHP函数递增一个PHP函数
我创建了使用单选按钮和一个提交按钮进行测验。我希望函数检查是否选择了一个特定的单选按钮,如果是这样,请在用户分数上加1。然而,被添加没有此功能是
function Score()
{
if(isset($_POST['correctAnswer']))
{
$answer=$_POST['correctAnswer'];
$_SESSION['score']=$userScore+1;
}
else
{
$_SESSION['score']=$_SESSION['score'];
}
}
,并在其所提交的表单
echo '<strong>'."$theQuestion".'</strong><br>';
?> <form name="correctAnswer" form method="post" action="quiz.php" onSubmit="Score()">
<?php
echo "$theAnswer1";?> <input type="radio" id="correct_answer" name="correctAnswer">
<?php
echo "<br>$theAnswer2"; ?> <input type="radio" id="wrong_answer1" name="wrongAnswer1">
<?php
echo "<br>$theAnswer3"; ?> <input type="radio" id="wrong_answer2" name="wrongAnswer2">
<?php
echo "<br>$theAnswer4"; ?> <input type="radio" id="wrong_answer3" name="wrongAnswer3">
<input type="hidden" name="score" value="userScore">
<br><input type="submit" value="Submit Answer">
</form>
希望你能帮助
什么是'$ userScore'? –
'$ _SESSION ['score'] = $ _ SESSION ['score']'完全没有。 – deceze