Well I am making a number guessing game. It works just fine. But if the person doesn't pick a number and just clicks submit, it says that you got the number wrong. How can I make it say something like "Please go back and select a number." Thanks to all that can help. Here is my current script with the radiobuttons to select a number.
<form action="if.php" method="post">
Please select a number to guess.<br>
<input type="radio"
name="num" value="1">1
<input type="radio"
name="num" value="2">2
<input type="radio"
name="num" value="3">3
<input type="radio"
name="num" value="4">4
<input type="radio"
name="num" value="5">5<br>
<input type="submit" value="Guess that number!">
</form>
<?php
$cpu_number = rand(1, 5);
If (isset ($_POST['num'])) {
$number = $_POST['num'];
}
If ($number == $cpu_number) {
echo "You guessed $number... Your number the same! You win!";
} elseif ($number != $cpu_number) {
echo "You guessed $number... Your number does not match. Sorry, you lose. The computer's number was $cpu_number.";
} elseif (noNumberSelected) {
echo "You haven't pressed a number. Please go back and select a number.";
}
?>