View unanswered posts | View active topics It is currently Wed Mar 22, 2023 3:11 am



Reply to topic  [ 1 post ] 
 Guess the Number (PHP game) 
Author Message
Junior Member

Joined: Sun Sep 13, 2009 4:08 pm
Posts: 54
Location: United States Of America
Post Guess the Number (PHP game)
A little PHP game, nothing big, just to keep users busy :D

[php]<?php
echo "<html><body>";
if ($_POST["guess"]) {
$guess=$_POST["guess"];
$res=rand(1,5);
if ($res == $guess) {
echo "Congratulations - you guessed the correct number - ".$guess."!";
}
else {
echo "Sorry - ".$guess." was not the correct number - the correct number was ".$res."!";
}
}
else {
echo "Guess a number:
";
echo "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
echo "1. <input type=\"radio\" name=\"guess\" value=\"1\">
";
echo "2. <input type=\"radio\" name=\"guess\" value=\"2\">
";
echo "3. <input type=\"radio\" name=\"guess\" value=\"3\">
";
echo "4. <input type=\"radio\" name=\"guess\" value=\"4\">
";
echo "5. <input type=\"radio\" name=\"guess\" value=\"5\">
";
echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\">";
echo "</form>";
}
echo "</body></html>";
?>
[/php]


Sun Sep 13, 2009 4:44 pm
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.