Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- $random_1 = rand(1, 3);
- if ($random_1 == '1' && $_POST['id'] == '1')
- {
- $uitslag = '0';
- }
- elseif ($random_1 == '1' && $_POST['id'] == '2')
- {
- $uitslag = '2';
- }
- elseif ($random_1 == '1' && $_POST['id'] == '3')
- {
- $uitslag = '1';
- }
- elseif ($random_1 == '2' && $_POST['id'] == '1')
- {
- $uitslag = '1';
- }
- elseif ($random_1 == '2' && $_POST['id'] == '2')
- {
- $uitslag = '0';
- }
- elseif ($random_1 == '2' && $_POST['id'] == '3')
- {
- $uitslag = '2';
- }
- elseif ($random_1 == '3' && $_POST['id'] == '1')
- {
- $uitslag = '2';
- }
- elseif ($random_1 == '3' && $_POST['id'] == '2')
- {
- $uitslag = '1';
- }
- elseif ($random_1 == '3' && $_POST['id'] == '3')
- {
- $uitslag = '0';
- }
- //Include database bestand (niet verplicht!)
- include 'db.php';
- }
- ?>
- <html>
- <head>
- <title>Steen, papier, schaar</title>
- </head>
- <body>
- <?php
- if (isset($uitslag))
- {
- if ($uitslag == '0')
- {
- echo'Gelijk!';
- }
- elseif ($uitslag == '1')
- {
- echo'Verloren';
- }
- elseif ($uitslag == '2')
- {
- echo'Gewonnen';
- }
- echo '<br /><br /> <a href="">Speel opnieuw</a>';
- }
- else
- {
- ?>
- <form method="POST">
- <select name="id">
- <option value="1">Steen</option>
- <option value="2">Papier</option>
- <option value="3">Schaar</option>
- </select>
- <input type="submit" value="SPEEL!"/>
- </form>
- <?php
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement