Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/repetitionSpecial/
rep1.php
rep2.php
rep3.php
rep4.php
rep5.php
rep6.php
rep1.php
40 lines UTF-8 Windows (CRLF)
<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('output_buffering', 0);
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8" />
<title>Repetiotion 1</title>
</head>
<body>
<?php
$talet;
$antalGissningar;
if (isset($_POST["nummer"])) {
$talet = $_POST["talet"];
$antalGissningar = $_POST["antalGissningar"]+1;
if ($talet == $_POST["nummer"]) {
echo("Bra jobbat");
}
else echo "Fel, gissa igen<br>";
echo "Du har gissat $antalGissningar gånger";
}
else{
$talet = rand(1,10);
$antalGissningar = 0;
}
?>
<h1>Gissa tal</h1>
<form method="post" action="">
<input type="number" name="nummer">
<input type="hidden" name="talet" value="<?php echo($talet); ?>">
<input type="hidden" name="antalGissningar" value="<?php echo($antalGissningar); ?>">
<br>
<input type="submit" name="gissa">
</form>
</body>
</html>