- <?php 
- // hier alle instellingen aanpassen 
- $Gmax = 10; // hier het maximale getal wat mag worden gebruikt in het spel 
- $Gmin = 1; // hier het laagste getal dat mag worden gebruikt (ik raad aan dit gewoon 1 te laten) 
- $boodschap_goed = 'Je hebt het goed'; // hier de boodschap als je het goed hebt 
- $boodschap_fout = 'Je hebt het helaas fout'; // hier de boodschap als het fout is. 
- $boodschap_opnieuw = 'Probeer het opnieuw'; // hier de boodschap om de game opnieuw te beginnen 
- // en vanaf hier niks meer wijzigen 
- ?> 
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
- <html xmlns="http://www.w3.org/1999/xhtml"> 
- <center> 
- <head> 
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
- <title>Hoger & Lager</title> 
- <style type="text/css"> 
- <!-- 
- body,td,th { 
- 	font-family: verdana; 
- 	font-size: 11px; 
- } 
- --> 
- </style></head> 
-   
- <body> 
- <table width="300"> 
-   <tr> 
-     <td align="left"><strong>Hoger & Lager V2</strong> 
- 	<br /> </td> 
-   </tr> 
-   <tr> 
-     <td align="left"> 
- 	<?php 
- 	if(isset($_POST['hoger']) || isset($_POST['lager'])) 
- 	{ 
- 		$getal1 = $_SESSION['getal1']; 
- 		$getal2 = $_SESSION['getal2']; 
- 	  } 
-   
- 	  if(isset($_POST['hoger'])) { 
- 		if($getal1 < $getal2) { 
- 		echo '<br>Getal 2 was: '; 
- 		echo '<br><a href="hogerlager.php">'.$boodschap_opnieuw.'</a>'; 
- 		$_SESSION['goed']++; 
- 		$_SESSION['totaal']++; 
- 	  } else { 
- 		echo '<br>Getal 2 was: '; 
- 		echo '<br><a href="hogerlager.php">'.$boodschap_opnieuw.'</a>'; 
- 		$_SESSION['fout']++; 
- 		$_SESSION['totaal']++; 
- 	  } 
- 	  } 
-   
- 	  if(isset($_POST['lager'])) { 
- 		if($getal1 > $getal2) { 
- 		echo '<br>Getal 2 was: '; 
- 		echo '<br><a href="hogerlager.php">'.$boodschap_opnieuw.'</a>'; 
- 		$_SESSION['goed']++; 
- 		$_SESSION['totaal']++; 
- 	  } else { 
- 		echo '<br><a href="hogerlager.php">'.$boodschap_opnieuw.'</a>'; 
- 		$_SESSION['fout']++; 
- 		$_SESSION['totaal']++; 
- 	  } 
- 	  } 
- 	} elseif(isset($_POST['statistiek'])) { 
- 	  echo 'Je hebt in totaal '.$_SESSION['totaal'].' keer gespeelt<br>'; 
- 	  ?> 
- 	  <table width="250"> 
- 	    <tr> 
- 		  <td width="50" align="left">Goed:</td> 
- 		  <td width="200" align="left"> 
- 		  <?php 
- 		  $goed_totaal1 = $_SESSION['goed']; 
- 		  $goed_totaal2 = $goed_totaal1 / $_SESSION['totaal'] * 100; 
- 		  $goed_totaal3 = round($goed_totaal2, 1); 
-   
- 		  echo ''.$goed_totaal3.'%'; 
- 		  ?> 
- 		  </td> 
- 		</tr> 
- 		<tr> 
- 		  <td width="50" align="left">Fout:</td> 
- 		  <td width="200" align="left"> 
- 		  <?php 
- 		  $fout_totaal1 = $_SESSION['fout']; 
- 		  $fout_totaal2 = $fout_totaal1 / $_SESSION['totaal'] * 100; 
- 		  $fout_totaal3 = round($fout_totaal2, 1); 
-   
- 		  echo ''.$fout_totaal3.'%'; 
- 		  ?> 
- 		  </td> 
- 		</tr> 
- 	  </table> 
- 	  <br /> 
- 	  <?php  
- 	  echo '<br><a href="hogerlager.php">'.$boodschap_opnieuw.'</a>'; 
-   
- 	} else { 
-   
- 	  $getal1 = $_SESSION['getal1'] = rand ($Gmin, $Gmax); 
- 	  $getal2 = $_SESSION['getal2'] = rand ($Gmin, $Gmax); 
-   
- 	  while($getal1 == $getal2) { 
- 		unset($_SESSION['getal2']); 
-   
- 		// $getal 2 opnieuw setten 
- 		$getal2 = rand($Gmin, $Gmax); 
- 	  } 
-   
- 	  $_SESSION['getal2'] = $getal2; 
-   
-   
- 	  echo 'Je ziet een getal tussen de '.$Gmin.' en de '.$Gmax.'<br>'; 
- 	  ?>  
- 	  Het eerste getal is:  <?php echo $getal1 ?>
- 	  <br><br> 
- 	  Is het 2e getal hoger of lager dan het eerste? <br>  
-   
- 	  <center> 
- 	  <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> 
- 		<input type="submit" name="hoger" value="Hoger"> 
- 		<input type="submit" name="lager" value="Lager"> 
- 	  </form> 
- 	  </center> 
-   
- 	<?php 
- 	} 
- 	?> 
- 	</td> 
-   </tr> 
-   <tr> 
-     <td align="left"><hr /><br /><?php 
- 	if(!isset($_SESSION['totaal'])) { 
- 	  $_SESSION['totaal'] = 0; 
- 	  echo 'Je hebt nu 0 keer gespeelt'; 
- 	} elseif($_SESSION['totaal'] == 0) { 
- 	  echo 'Je hebt nu 0 keer gespeelt'; 
- 	} else { 
- 	  echo 'Je hebt nu '.$_SESSION['totaal'].' keer gespeelt'; 
- 	} 
- 	if(!isset($_SESSION['goed'])) { 
- 	  $_SESSION['goed'] = 0; 
- 	  echo 'Je hebt er 0 goed'; 
- 	} elseif($_SESSION['totaal'] == 0) { 
- 	  echo 'Je hebt er 0 goed'; 
- 	} else { 
- 	  echo 'je hebt er '.$_SESSION['goed'].' goed'; 
- 	} 
- 	if(!isset($_SESSION['fout'])) { 
- 	  $_SESSION['fout'] = 0; 
- 	  echo 'Je hebt er 0 fout'; 
- 	} elseif($_SESSION['fout'] == 0) { 
- 	  echo 'Je hebt er 0 fout'; 
- 	} else { 
- 	  echo 'Je hebt er '.$_SESSION['fout'].' fout'; 
- 	} 
- 	?> 
- 	<br /><br /> 
- 	<form name="statistieken" method="post" action="<? $_SERVER['PHP_SELF']; ?>"> 
- 	  <input type="submit" name="statistiek" value="Statistieken"> 
- 	</form></td> 
-   </tr> 
- </table> 
- </body> 
- </center> 
- </html>