Add some code
This commit is contained in:
@@ -1,5 +1,59 @@
|
||||
<?php
|
||||
|
||||
phpinfo();
|
||||
session_name(get_current_user() . "hangman");
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['toGuess'])) {
|
||||
header("Location: hangman-init.php");
|
||||
}
|
||||
|
||||
$mask = implode(" ", $_SESSION['mask']);
|
||||
echo <<<END
|
||||
<h1>Wörter raten</h1>
|
||||
<p>$mask</p>
|
||||
END;
|
||||
|
||||
echo <<<END
|
||||
<form action="/hangman-guess.php" method="post">
|
||||
END;
|
||||
//Output all buttons
|
||||
$alphabet = range('A', 'Z'));
|
||||
foreach($alphabet as $abc) {
|
||||
echo <<<END
|
||||
<button name="$abc" type="submit" value="$abc">$abc</button>
|
||||
END;
|
||||
|
||||
}
|
||||
|
||||
echo <<<END
|
||||
</form>
|
||||
END;
|
||||
|
||||
//Show errorCount
|
||||
$errors = $_SESSION['errorCount'];
|
||||
echo <<<END
|
||||
<p>$errors / 8</p>
|
||||
END;
|
||||
|
||||
//Show the restart link
|
||||
$state = $_SESSION['state'];
|
||||
if ($state > 0) {
|
||||
echo <<<END
|
||||
<a href="hangman-init.php">Neues Spiel starten</a>
|
||||
END;
|
||||
}
|
||||
|
||||
if ($errors > 8) {
|
||||
$guessword = $_SESSION['toGuess'];
|
||||
echo <<<END
|
||||
<p>Das richtige Wort wäre $guessword gewesen!</p>
|
||||
END;
|
||||
}
|
||||
|
||||
//HOW MUCH IS THE FISH
|
||||
echo <<<END
|
||||
<img src="fish-$errors.svg">
|
||||
END;
|
||||
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user