Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Day 9 - Lets Make A Game - Part 2 - Become PHP Expert in 30 days

  1. #11
    Join Date
    May 2014
    Posts
    21

    Default

    http://php.flashwebhost.com/austin/day9.php

    Code:
    <html>
    <body>
    <?php
    if(isset($_POST['secretNumber'])) {
      $secretNumber = $_POST['secretNumber']; }
      else {
      $secretNumber = rand(10,100); }
      
      if(isset($_POST['userNumber'])){
        $userNumber = $_POST['userNumber'];
        
        if ($userNumber<$secretNumber)
        echo strtolower('<h3 style="color:red"> NUMBER is  SMALLER</h3>');
        
        else if($userNumber>$secretNumber)
        echo strtoupper('<h3 style="color:blue">your number is bigger</h3>');
        
        else
        echo '<h3 style="color:green">YOU WON BUDDY</h3>';
        
    }
    ?>
        <form method="POST" action="">
        Enter your Number : <input type="text" name ="userNumber">
        <button style="color:green" type="submit">Go</button>
        <input type="hidden" name="secretNumber" value="<?php echo $secretNumber; ?>">
        </form>
    </body>
    </html>

  2. #12
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by Austinwhite View Post
    so in this code the value of the secret number is echoed where??

    i mean... this code is the one to print the value of SecretNumber so does it print the value in the server memory or something? :P
    Stop trying to hack game. You don't need Cheat Engine for this.

    Just view source code, you will see it
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  3. #13
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by Austinwhite View Post
    http://php.flashwebhost.com/austin/day9.php

    Code:
    <html>
    <body>
    <?php
    if(isset($_POST['secretNumber'])) {
      $secretNumber = $_POST['secretNumber']; }
      else {
      $secretNumber = rand(10,100); }
      
      if(isset($_POST['userNumber'])){
        $userNumber = $_POST['userNumber'];
        
        if ($userNumber<$secretNumber)
        echo strtolower('<h3 style="color:red"> NUMBER is  SMALLER</h3>');
        
        else if($userNumber>$secretNumber)
        echo strtoupper('<h3 style="color:blue">your number is bigger</h3>');
        
        else
        echo '<h3 style="color:green">YOU WON BUDDY</h3>';
        
    }
    ?>
        <form method="POST" action="">
        Enter your Number : <input type="text" name ="userNumber">
        <button style="color:green" type="submit">Go</button>
        <input type="hidden" name="secretNumber" value="<?php echo $secretNumber; ?>">
        </form>
    </body>
    </html>
    Congratulation, you are game developer now. Ask user name, show score at the end based on number of try, add some nice image, shinny buttons and music, ready to go :)
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  4. #14
    Join Date
    Apr 2005
    Posts
    46,704

    Default

    Code:
    <html>
    <body>
    
    <h1>Number Guessing Game.</h1>
    
    <?php
    
    if (isset($_POST['secretNumber'])) {
        $secretNumber = $_POST['secretNumber'];
    } else {
        $secretNumber = rand(1,20);
    }
    
    if (isset($_POST['userNumber'])) {
        $userNumber = $_POST['userNumber'];
    
        if ($secretNumber > $userNumber) {
            echo '<h1 style="color:chocolate">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:firebrick">You win the game.</h1>';
        }
    }
    
    ?>
    
    <form method="POST" action="">
        Guess A 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 1 and 20.
    * 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>
    http://php.flashwebhost.com/mini/game_1.php

  5. #15
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    Come on, play and win this game
    http://php.flashwebhost.com/vineesh/day9/day_9_ex_3.php

    PHP Code:
    <html>
    <body style="background-color:#DADADA">

    <h1 style="color:#E237C8"><u>Number Guessing Game</u></h1>

    <?php

    if (isset($_POST['secretNumber'])) {
       
    $secretNumber $_POST['secretNumber'];
    } else {
       
    $secretNumber rand(1,33);
    }

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

       if (
    $secretNumber $userNumber) {
        echo 
    '<h2 style="color:#EE0F21">Heyy...thats very small number.</h2>';
       } else if (
    $secretNumber $userNumber) {
        echo 
    '<h2 style="color:#EE0F21">Heyy...thats a big number</h2>';
       } else {
        echo 
    '<h3 style="color:#0FA7EE">Congratulations..! <br>' 'The Number you entered (' $secretNumber ') is correct and You won the game!!!</h3>';
       }
    }

    ?>


    <form method="POST" action="">
    <font style="color:#00B789">Enter Your Number:</font> <input type="text" name="userNumber">
    <button type="submit">Check!</button>
    <input type="hidden" name="secretNumber" value="<?php echo $secretNumber ?>">
    <form>

    </body>
    </html>

  6. #16
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 9 PHP PROGRAMMING

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

    PHP Code:

    <html><body>
    <h1>NUMBER GUESSING GAME</h1>
    <?php
    if (isset($_POST['secretNumber'])) {
    $secretNumber $_POST['secretNumber'];
    } else {
    $secretNumber rand(1,10);
    }
    if (isset(
    $_POST['userNumber'])) {
    $userNumber $_POST['userNumber'];
    if (
    $secretNumber $userNumber) {
    echo 
    '<h2>Your Number is Small</h2>';
    } else if (
    $secretNumber $userNumber) {
    echo 
    '<h2>Your Number is Big</h2>';
    } else {
    echo 
    '<h2>You Won The Game</h2>';
    }
    }
    ?>
    <form method="POST" action="">
    Enter Your 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 1 and 10.* 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>

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

    Default

    DAY 9 PHP PROGRAMMING

    http://php.flashwebhost.com/ramesh/d...st_method2.php

    PHP Code:
    <html>
    <body>

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

    <?php
    if (isset($_POST['secretNumber'])){
        
    $secretNumber $_POST['secretNumber'];
    }    else {
        
    $secretNumber rand(1,99);
    }

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

        if (
    $secretNumber $userNumber){
            echo 
    '<h1 style="color:red">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:green">You win the game.</h1>';
        }
    }

    ?>

    <form method="POST" action="">
    Enter Your:
    <input type="text" name="userNumber">
    <button type="submit">Check</button>
    <input type="hidden" name="secretNumber" value="<?php echo $secretNumber?>">
    </form>
    </body>
    </html>

Page 2 of 2 FirstFirst 12

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
  •