Results 1 to 10 of 16

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/number_guess.php

    Code:
    <html>
    <body>
    
    
    <h1>Guess My Number!</h1>
    
    
    <?php
    
    
    if (isset($_GET['secretNumber'])) {
    $secretNumber = $_GET['secretNumber'];
    } else {
    $secretNumber = rand(10,800);
    }
    
    
    if (isset($_GET['userNumber'])) {
    $userNumber = $_GET['userNumber'];
    
    
    if ($secretNumber > $userNumber) {
    echo '<h1 style="color:LimeGreen">Your guess is too low.</h1>';
    } else if ($secretNumber < $userNumber) {
    echo '<h1 style="color:red ">Your guess is too high.</h1>';
    } else {
    echo '<h1 style="color:green">You win the game.</h1>';
    }
    }
    
    
    ?>
    
    
    <form method="GET" action="">
    Enter letter: <input name="userNumber" type="text">
    <button type="submit">Check</button>
    <input type="hidden" name="secretNumber" value="<?php echo $letter; ?>">
    </form>
    
    
    <h2>Tips for Playing Game:</h2>
    
    
    <pre>
    * Server will pick a secret letter between 10 and 800.
    * You guess what letter it is.
    * If your guess is too high or too low, Server will give you a hint.
    </pre>
    
    
    </body>
    </html>
    Last edited by stefin; 05-19-2014 at 03:53 PM.

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
  •