[英]PHP exercise with cookies
當我回答正確的問題時,我需要得到+10的分數,但是它在這里不起作用,這是我的代碼:
嗨,謝謝你的回答,我現在正在嘗試,但是如果我回答的是好問題,分數不會增加10:
<?php
// de functie rand() bepaalt een random getal tussen het eerste en tweede opgegeven getal
$getal1 = rand (1, 10);
$getal2 = rand (1, 20);
$score = 0;
if(isset($_POST['verzend'])){
$antwoord = $_POST['uitkomst'];
$somantwoord = $getal1 * $getal2;
if($antwoord == $somantwoord)
{
$score + 10;
}
}
echo $score;
的HTML
<form method='post' action='index.php'>
<input name='getal1' type='text' disabled value='$getal1'> *
<input name='getal2' type='text' disabled value='$getal2'> =
<input name='uitkomst' type='text' value='' id='uitkomst'>
<input type='submit' value='verzend' name='verzend'>
</form>
試試這個代碼:
<?php
// de functie rand() bepaalt een random getal tussen het eerste en tweede opgegeven getal
$getal1 = rand(1, 10);
$getal2 = rand(1, 20);
$score = 0;
if(isset($_POST['verzend'])) {
$antwoord = (int)$_POST['uitkomst'];
$somantwoord = $getal1 * $getal2;
if($antwoord === $somantwoord) {
$score += 10;
}
}
echo $score;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.