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
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default Guess Winning number Game using PHP

    http://php.flashwebhost.com/sibichan...ing_number.php

    PHP Code:

    <html><body>
    <h1>Winning Number Guessing Game.</h1>
    <?php
    if (isset($_GET['winningNumber'])) {

        
    $winningNumber $_GET['winningNumber'];

    } else {

        
    $winningNumber rand(1,10);}
    if (isset(
    $_GET['luckyNumber'])) {

        
    $luckyNumber $_GET['luckyNumber'];
        if (
    $winningNumber != $luckyNumber){

            echo 
    '<h1 style ="color:#009900">Your lucky number is ' $luckyNumber.'<br> The winning Number is ' $winningNumber .'<br> No winnings this time. Please try again later </h1>';

            echo 
    '<hr>';    }      else {

             echo 
    '<h1 style ="color:#009900"> Your lucky number is ' $luckyNumber.'<br> The winning Number is ' $winningNumber .'<br><span style=color:red>Hurray ! you won the game </h1>';

            echo 
    '<hr>';

        }

    }
    ?>
    <form method="GET" action="">    Enter your Number lucky No (from 1 to 10): <input name="luckyNumber" type="text">    <button type="submit">Check</button>    <input type="hidden" name="winningNumber" value="<?php echo $winningNumber?>"></form>

    </body></html>
    Last edited by Vahaa11; 05-19-2014 at 11:42 AM.

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
  •