arman
Новичок
Дата регистрации:
01.03.2013 15:29:05
Сообщений: 7
Код:
<?php
$message = "Guess the number in the range from 0 to 10000!";
if (isset($_POST["guess"])) {
$number = $_POST["number"];
$hidden_number = $_POST["hidden_number"];
$s = sqrt($hidden_number);
if ($number < $s) {
$message = "Your number is less than $number";
}
elseif ($number > $s) {
$message = "Your number is more than $number";
}
elseif ($number == $s) {
$message = "Congratulations! You won! <br/> Guess new number!";
$hidden_number = rand(0, 10000);
}
}
else {
$number = 0;
$hidden_number = rand(0, 10000);
}
?>
<html>
<head>
<title>Guess the number!</title>
</head>
<body>
<h2><?php echo $message; ?></h2>
<form method = "post">
<input type = "text" name = "number" value = "<?php echo $number ?>" />
<input type = "submit" name = "guess" value = "Guess!" />
<input type = "hidden" name = "hidden_number" value = "<?php echo $s ?>" />
</form>
</body>
</html>