Guess the Number
Monday January 8, 2007
One simple game you can write with PHP is a guess the number game. This allows a user to guess a number between 1-100 (or whatever you set the range to.) The script then tells them if their guess is too high, too low, or if they have won.


Good tutorial, but it wouldn’t run on my PHP server, which doesn’t translate posted values straight to variables. I appended this code to the start of my program;
//Get any posted numbers
if($Num=$_POST['Num']);
if($x=$_POST['x']);
The statements are nested inside IF statements, so they don’t pass any errors if no values are posted. The rest of your program works like a charm! Thanks for this great tutorial!