lundi 28 mars 2016

I am trying to write a function that generates a random number that will stay under my user input that i type in for php

I need to generate a random integer that doesnt exceed the integer that is entered in my user input. Im just very confused how to write it as a

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://ift.tt/mOIMeg">
    <html lang="EN" dir="ltr" xmlns="http://ift.tt/lH0Osb">
        <head>
            <title>Roll The Die</title>
        </head>
        <body>
    <center>
    <h1>Dice Game</h1>

//Php form im just confused on how to generate a random number that stays under my user input number and that is also attached to the form

     <?php

    if (filter_has_var(INPUT_POST, 'userDie')){
        $roll = rand();
        $userDie = filter_has_var(INPUT_POST, "userDie");
        echo"You rolled a $roll";
    }
    //there's no input. Create the form
     print <<< HERE
    <form action = "" method = "post">
    <fieldset>
    <label>Please Enter a number to Roll</label>
     <input type = "text" 
     name = "userDie" /> 
     <button type = "submit">
      submit 
     </button>
    </fieldset>
     </form> 
    HERE;

    // end 'value exists' if
     ?>
    </body>
    </html>




Aucun commentaire:

Enregistrer un commentaire