gewinnspiel-2.php
Quell Code
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$level1_horinzontaleboxen=4;
$level1_vertikale_boxen=4;
$level2_horinzontaleboxen=7;
$level2_vertikale_boxen=14;
$level3_horinzontaleboxen=9;
$level3_vertikale_boxen=24;
$pfad_this_datei=$_SERVER['PHP_SELF'];
if(isset($_POST['level'])){
$level=$_POST['level'];
}else{
$level='Error';
}
if(isset($_POST['link'])){
$link=$_POST['link'];
}else{
$link='Error';
}
$teil=1;
if($level==1){
$teil=3;
}
if($level==2){
$teil=7;
}
if($level==3){
$teil=10;
}
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="description" content="Gewinnspiel Level <?php echo $level; ?> und Link <?php echo $link; ?>">
<title>Gewinnspiel Level <?php echo $level; ?> und Link <?php echo $link; ?></title>
<style>
*{
margin: 0;
padding: 0;
}
nav{
position: fixed;
top: 0;
background: #eee;
height: 60px;
width: 100%;
background:grey;
}
.navbar-list {
list-style: none;
display:flex;
}
.navbar-item {
display:block;
flex:1;
text-align:center;
}
.navbar-link {
line-height: 60px;
color:black;
text-decoration: none;
font-weight: 600;
font-size: 16px;
width: 100%;
}
.navbar-submenu {
display: none;
position: absolute;
list-style: none;
width:calc(100% / <?php echo $teil; ?>);
text-align:center;
}
.navbar-item:hover > .navbar-submenu {
display: block;
}
li{
background:grey;
color:white;
width:100%;
cursor: pointer;
}
li button{
width:100%;
}
a{
text-decoration: none;
line-height: 30px;
color:white;
font-size: 14px;
}
main{
margin-top:100px;
}
main a{
font-size:50px;
color:green;
}
main *{
text-align:center;
margin:50px auto;
}
</style>
</head>
<body>
<form method="POST">
<nav class="navbar">
<ul id="nav" class="navbar-list">
<?php
if(isset($_POST['level'])){
$level=$_POST['level'];
if($level==1){
$aend=5;
$bend=5;
}
if($level==2){
$aend=8;
$bend=15;
}
if($level==3){
$aend=10;
$bend=25;
}
if(isset($_POST['GO'])){
$l1=rand(1, $level1_horinzontaleboxen).'.'.rand(1, $level1_vertikale_boxen);
$l2=rand(1, $level2_horinzontaleboxen).'.'.rand(1, $level2_vertikale_boxen);
$l3=rand(1, $level3_horinzontaleboxen).'.'.rand(1, $level3_vertikale_boxen);
file_put_contents('gewinn-helfer.txt', $l1.','.$l2.','.$l3);
}
for($a=1;$a<$aend;$a++){
echo "<li class='navbar-item'><button name='' class='navbar-link'>Menue $a</button>";
echo '<ul class="navbar-submenu">';
for($b=1;$b<$bend;$b++){
echo "<li><button name='link' value='$a.$b'>Item $b</button></li>";
}
echo '</ul></li>';
}
}
?>
</ul>
<input type="hidden" name="level" value="<?php echo $level; ?>">
</nav>
</form>
<main>
<?php if(isset($_POST['level'])){ ?>
<h1>Gewinnspiel Level <?php echo $level; ?></h1>
<?php }else{ ?>
<form method="POST">
<input type="hidden" name="level" value="1">
<button name="GO" type="submit">Starte das Game</a>
</form>
<?php } ?>
<p>klicke durch die Links bis du hinweiss zum nächsten Level hast</p>
<?php
$helper=file_get_contents('gewinn-helfer.txt');
$he=explode(',',$helper);
if(isset($_POST['link']) and isset($_POST['level'])){
if($_POST['link']==$he[0]){
echo '
<form method="POST" style="font-size:60px;color:red">
Glückwunsch<br>hier geht es weiter zu Level 2<br>
<input type="hidden" name="level" value="2">
<button name="GO" type="submit">Weiter Level 2</a>
</form>';
}
}
if(isset($_POST['link']) and isset($_POST['level'])){
if($_POST['link']==$he[1]){
echo '
<form method="POST" style="font-size:60px;color:red">
Glückwunsch<br>hier geht es weiter zu Level 3<br>
<input type="hidden" name="level" value="3">
<button name="GO" type="submit">Weiter Level 3</a>
</form>';
}
}
if(isset($_POST['link']) and isset($_POST['level'])){
if($_POST['link']==$he[2]){
echo "<div id='info'>
<h2>Glückwunsch<br> du hast gewonnen</h2>
<a href='https://soforthilfe-forum.de' style='font-size:60px;color:red'>klicke hier für dein Gewinn</a>
</div>";
}
}
?>
</main>
</body>
</html>