Advertisement
Guest User

Steen Papier Schaar

a guest
Sep 26th, 2010
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2. if ($_SERVER['REQUEST_METHOD'] == 'POST')
  3.     {
  4.         $random_1 = rand(1, 3);
  5.            
  6.             if ($random_1 == '1' && $_POST['id'] == '1')
  7.                 {
  8.                 $uitslag = '0';
  9.                 }
  10.                
  11.             elseif ($random_1 == '1' && $_POST['id'] == '2')
  12.                 {
  13.                 $uitslag = '2';
  14.                 }
  15.                
  16.             elseif ($random_1 == '1' && $_POST['id'] == '3')
  17.                 {
  18.                 $uitslag = '1';
  19.                 }
  20.            
  21.             elseif ($random_1 == '2' && $_POST['id'] == '1')
  22.                 {
  23.                 $uitslag = '1';
  24.                 }
  25.                
  26.             elseif ($random_1 == '2' && $_POST['id'] == '2')
  27.                 {
  28.                 $uitslag = '0';
  29.                 }
  30.                
  31.             elseif ($random_1 == '2' && $_POST['id'] == '3')
  32.                 {
  33.                 $uitslag = '2';
  34.                 }
  35.            
  36.             elseif ($random_1 == '3' && $_POST['id'] == '1')
  37.                 {
  38.                 $uitslag = '2';
  39.                 }
  40.                
  41.             elseif ($random_1 == '3' && $_POST['id'] == '2')
  42.                 {
  43.                 $uitslag = '1';
  44.                 }
  45.                
  46.             elseif ($random_1 == '3' && $_POST['id'] == '3')
  47.                 {
  48.                 $uitslag = '0';
  49.                 }
  50.                    
  51.                 //Include database bestand (niet verplicht!)
  52.                 include 'db.php';
  53.                
  54.                
  55.                
  56.                
  57.     }
  58. ?>
  59.  
  60.                 <html>
  61.                     <head>
  62.                         <title>Steen, papier, schaar</title>
  63.                     </head>
  64.                         <body>
  65.                            
  66.                                 <?php
  67.                                     if (isset($uitslag))
  68.                                     {
  69.                                    
  70.                                         if ($uitslag == '0')
  71.                                             {
  72.                                                 echo'Gelijk!';
  73.                                             }
  74.                                         elseif ($uitslag == '1')
  75.                                             {
  76.                                             echo'Verloren';
  77.                                             }
  78.                                         elseif ($uitslag == '2')
  79.                                             {
  80.                                                 echo'Gewonnen';
  81.                                             }
  82.                                             echo '<br /><br /> <a href="">Speel opnieuw</a>';
  83.                                     }
  84.                                         else
  85.                                             {
  86.                                 ?>
  87.                                                 <form method="POST">
  88.                                                     <select name="id">
  89.                                                         <option value="1">Steen</option>
  90.                                                         <option value="2">Papier</option>
  91.                                                         <option value="3">Schaar</option>
  92.                                                     </select>
  93.                                
  94.                                                         <input type="submit" value="SPEEL!"/>
  95.                                                 </form>
  96.                                         <?php
  97.                                             }
  98.                                         ?>
  99.                            
  100.                         </body>
  101.                 </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement