Our Scripts Vault contains many game scripts that you can use to create your own game!
<?php$Message = '';if (isset($_POST['Submit'])) { $Guess = trim(intval($_POST['guess'])); $Random = mt_rand('1', '100'); if ($Guess > '100' OR $Guess < '1') $Message = 'Numbers Between 1-100 Only Please!'; else if (!ctype_digit($Guess)) $Message = 'No Letters Fool!'; else if ($Guess == $Random) $Message = 'Congratulations!<br /> You Guessed The Correct Number: '.$Guess; else $Message = 'Unlucky!<br /> You Guessed: '.$Guess.'! The Number was '.$Random;}echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Guess The Number!</title> <style type="text/css"> body { background-color : #131c20; font-family : Arial; font-size : 15px; color : #92aab8; width : 405px; } div.LBox { float : left; width : 50px; padding-right : 5px; } div.RBox { clear : right; } img { border : 0; } </style> </head> <body> <div> <h3>Guess The Number!</h3> Numbers Are Between 1-100.<br /><br />'; echo sprintf("%s", $Message); echo ' <br /><br />'; echo sprintf("<form method='post' action='%s'>", $_SERVER['PHP_SELF']); echo ' <div class="LBox">Guess:</div> <div class="RBox"><input type="text" name="guess" /><br /></div> <div class="LBox"> </div> <div class="RBox"><input type="submit" value="Guess!" name="Submit" /></div> </form> <br /> <br /> <a href="http://validator.w3.org/check?uri=referer"> <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" style="width:88px;height:31px" /> </a> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" style="width:88px;height:31px" /> </a> </div> </body></html>';?>
Functions I used
echo()
Like it's essential neither are isset, if/elseif/else, all are language constructs but in this case it's rather playing with words
Also, please do not use the report post function for anything other than to report forum violations.