session cookie

This commit is contained in:
Walter Hupfeld 2024-02-20 16:06:57 +01:00
parent 85ee0fe91b
commit 527308b201
3 changed files with 32 additions and 19 deletions

View File

@ -13,15 +13,18 @@
header("Location: setup.php"); header("Location: setup.php");
} }
*/ */
// Starte die Session
session_start();
if (isset($_GET['d'])) {
$strDistrict=$_GET['d'];
$_SESSION['district'] = $_GET['d'];
} else if (isset($_SESSION['district'])) {
$strDistrict=$_SESSION['district'];
}
else {
header("Location: start.php");
}
if (isset($_GET['d'])) {
$strDistrict=$_GET['d'];
} else {
header("Location: start.php");
}
require("config.db.php");
require("config.php"); require("config.php");
require_once("lib/functions.php"); require_once("lib/functions.php");
@ -103,10 +106,10 @@
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="index.php?ref=1?d=<?=$strDistrict?>">Karte <span class="sr-only">(current)</span></a> <a class="nav-link" href="index.php?ref=1">Karte <span class="sr-only">(current)</span></a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="liste.php?d=<?=$strDistrict?>">Liste</a> <a class="nav-link" href="liste.php">Liste</a>
</li> </li>
<!-- District --> <!-- District -->
<form method="GET" action="index.php"> <form method="GET" action="index.php">

View File

@ -9,11 +9,16 @@
******************************** */ ******************************** */
if (!file_exists("config.db.php")) { session_start();
header("Location: setup.php"); if (isset($_GET['d'])) {
$strDistrict=$_GET['d'];
$_SESSION['district'] = $_GET['d'];
} else if (isset($_SESSION['district'])) {
$strDistrict=$_SESSION['district'];
}
else {
header("Location: start.php");
} }
$strDistrict = (isset($_GET['d'])) ? $_GET['d'] : "hamm";
require("config.php"); require("config.php");
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -61,10 +66,10 @@
<div class="collapse navbar-collapse" id="navbars"> <div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="index.php?ref=1&d=<?=$strDistrict?>">Karte</a> <a class="nav-link" href="index.php?ref=1">Karte</a>
</li> </li>
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="liste.php?d=<?=$strDistrict?>">Liste <span class="sr-only">(current)</span></a> <a class="nav-link" href="liste.php">Liste <span class="s"r-only">(current)</span></a>
</li> </li>
<!-- District --> <!-- District -->
<form method="GET" action="index.php"> <form method="GET" action="index.php">

View File

@ -1,5 +1,5 @@
<?php <?php
require_once("config.db.php");
require("config.php"); require("config.php");
$directory = $_SERVER['REQUEST_URI']; $directory = $_SERVER['REQUEST_URI'];
@ -30,8 +30,13 @@
</style> </style>
</head> </head>
<body> <body>
<h1><?=$strTitle?></h1>
<div class="container"> <div class="container">
<h1><?=$strTitle?></h1>
<div class="jumbotron">
<img src="<?=$strLogo?>" />
<?=$strIntroText?>
</div>
<div> <div>
<form method="GET" action="index.php"> <form method="GET" action="index.php">
<select name="d" style="float:left;margin-top:0.5em;margin-right:0.5em;" onchange="this.form.submit()"> <select name="d" style="float:left;margin-top:0.5em;margin-right:0.5em;" onchange="this.form.submit()">