Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2009, 11:22 PM
Registered User
 
Join Date: Sep 2009
Posts: 6
Thanks: 1
Thanked 1 Time in 1 Post
Post 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>

************************************************** ******





Similar Threads
Thread Thread Starter Forum Replies Last Post
Choice of database's for attempt at commercializat TomW Access VBA 3 November 21st, 2008 09:08 AM
user function attempt demac43 Excel VBA 3 November 8th, 2006 05:59 PM
A connection attempt failed because the connected purtimalhotra .NET Web Services 0 February 5th, 2006 06:58 AM
Please Help! Attempt to create a login page nvillare Classic ASP Basics 8 August 12th, 2003 09:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.