how to increase number of attempt
Hello friend, I am new user of this site. I saw so many questions and answer provided by you. That all are awesome. This is my Thread..
My question is how can i increase the number of attempts by user so that i can stop him after 3 or 4 attempts..... I am pasting the code. Please reply me..............
************************************************** *****
<?php
$message="";
$num = 23;
global $attempt;
$guess = $_POST['guess'];
$attempt = (isset($attempt)) ? ++$attempt : 0;
if($attempt > 3){
exit;
}
if (!isset($guess)){
$message = "Welcome to guessing machine.";
}
elseif( $guess < $num ){
$message = "Your guess is less than the original, Try again";
}
elseif( $guess > $num ){
$message = "Your guess is more than the original, Try again";
}
else{
$message = "You got the right answer. Congratulation!!!!!!";
}
?>
<html>
<head>
<title> Number guessing machine2.0 </title>
</head>
<body>
<h1>
<?php
echo $message;
echo "<br> Your tried $attempt times.";
?>
</h1>
<form action="<?php echo $_SERVER[PHP_SELF] ?>" method="POST">
<!-- <form action="guessnumber1.php" method="POST"> -->
Enter your number:
<input type="text" name="guess">
<input type="submit" value="Check">
</form>
</body>
</html>
************************************************** ******
|