Advertisement
MBrendecke

Würfel

Mar 23rd, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2.     <head>
  3.         <title>Slice & Dice</title>    
  4.     </head>
  5.     <body>
  6.         <?php
  7.             $sites = $_POST['sites'] ?: '6';
  8.             $count = $_POST['count'] ?: '1';
  9.         ?>
  10.         <form id="dice" action="index.php" method="post">
  11.             <table style="width:100%">
  12.                 <tr>
  13.                     <td><label for="sites">Seiten:</label></td>
  14.                     <td><input type="text" id="sites" name="sites" value="<?= $sites ?>" autofocus /></td>
  15.                 </tr>
  16.                 <tr>
  17.                     <td><label for="count">Anzahl:</label></td>
  18.                     <td><input type="text" id="count" name="count" value="<?= $count ?>" /></td>
  19.                 </tr>
  20.                 <tr>
  21.                     <td><label>Würfeln:</label></td>
  22.                     <td><input type="submit" value="Würfeln" name="dice" /></td>
  23.                 </tr>
  24.                 <tr>
  25.                     <td><label>Ergebnis:</label></td>
  26.                     <td>
  27.                         <?php
  28.  
  29.                         for ($i = 0; $i < $count; $i++) {
  30.                             echo rand(1, $sites) . ' ';
  31.                         }
  32.                         ?>
  33.                     </td>
  34.                 </tr>
  35.             </table>
  36.         </form>
  37.     </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement