<!DOCTYPE html>
<head>
<title>Slice & Dice</title>
</head>
<body>
<?php
$sites = $_POST['sites'] ?: '6';
$count = $_POST['count'] ?: '1';
?>
<form id="dice" action="index.php" method="post">
<table style="width:100%">
<tr>
<td><label for="sites">Seiten:</label></td>
<td><input type="text" id="sites" name="sites" value="<?= $sites ?>" autofocus /></td>
</tr>
<tr>
<td><label for="count">Anzahl:</label></td>
<td><input type="text" id="count" name="count" value="<?= $count ?>" /></td>
</tr>
<tr>
<td><label>Würfeln:</label></td>
<td><input type="submit" value="Würfeln" name="dice" /></td>
</tr>
<tr>
<td><label>Ergebnis:</label></td>
<td>
<?php
for ($i = 0; $i < $count; $i++) {
echo rand(1, $sites) . ' ';
}
?>
</td>
</tr>
</table>
</form>
</body>
</html>
Comments