Reputation: 153
i need to get score +10 when i answer the question right but it is not working here is my code:
Hi thanks for the answers, i am now trying this but the score isnt going up by 10 if i answer the question good:
<?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>
Upvotes: 0
Views: 297
Reputation:
Try this code:
<?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;
Upvotes: 1