Results 1 to 10 of 16

Thread: Day 8 - Lets Make A Game - Part 1 - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 8 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/day_8_ex_2.php

    PHP Code:

    <html><body>
    <h1>NUMBER GUESSING GAME</h1>
    <?php
    if (isset($_GET['secretNumber'])) {
    $secretNumber $_GET['secretNumber'];
    } else {
    $secretNumber rand(90,100);
    }
    if (isset(
    $_GET['userNumber'])) {
    $userNumber $_GET['userNumber'];
    if (
    $secretNumber $userNumber) {
    echo 
    '<h1 style="color:blue">Your number is too SMALL.</h1>';
    } else if (
    $secretNumber $userNumber) {
    echo 
    '<h1 style="color:green">Your number is too BIG.</h1>';
    } else {
    echo 
    '<h1 style="color:red">You Win The Game</h1>';
    }
    }
    ?>
    <form method="GET" action="">
    Enter Number: <input name="userNumber" type="text">
    <button type="Submit">Check</button>
    <input type="hidden" name="secretNumber" value="<?php echo $secretNumber?>">
    </form>
    <h2>How to Play:</h2>
    <pre>* Server will pick a secret number between 90 and 100.* You guess what number it is.* If your guess is too high or too low, Server will give you a hint.* See how many turns it takes you to win!</pre>
    </body></html>

  2. #2
    Join Date
    Jan 2008
    Location
    india,kerala-god's own country
    Posts
    14,007

    Default

    DAY 8 PHP PROGRAMMING

    http://php.flashwebhost.com/ramesh/day-8/game_3.php

    PHP Code:
    <html>
    <body>

    <h1 style="color:red">Number Guessing Game.</h1>

    <?php

    if (isset($_GET['secretNumber'])) {
        
    $secretNumber $_GET['secretNumber'];
    } else {
        
    $secretNumber rand(5,15);
    }

    if (isset(
    $_GET['userNumber'])) {
        
    $userNumber $_GET['userNumber'];

        if (
    $secretNumber $userNumber) {
            echo 
    '<h1 style="color:red">Your number is too SMALL.</h1>';
        } else if (
    $secretNumber $userNumber) {
            echo 
    '<h1 style="color:blue">Your number is too BIG.</h1>';
        } else {
            echo 
    '<h1 style="color:green">You win the game.</h1>';
        }
    }

    ?>

    <form method="GET" action="">
        <font style="color:green">Enter Number:</font>
        <input name="userNumber" type="text">
        <button type="submit">Check</button>
        <input type="hidden" name="secretNumber" value="<?php echo $secretNumber?>">
    </form>
    </body>
    </html>

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •