district select

This commit is contained in:
Walter Hupfeld 2024-02-22 14:30:28 +01:00
parent f695c98fc3
commit f8b8feee5b
5 changed files with 50 additions and 7 deletions

View File

@ -138,6 +138,24 @@
</form> </form>
<?php endif; ?> <?php endif; ?>
<br><br><br> <br><br><br>
<h2>Auswahl Kreise und kreisfreie Städte</h2>
<form method="post" id="districtform" action="district_chk.php">
<?php
$strSQL="select * from district order by district";
$result = $db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strChecked= ($row['active']==1) ? "checked='checked'" : "";
$strValue=$row['active'];
$strDistrict=$row['district'];
echo "<input type='checkbox' $strChecked id='$strDistrict' name='$strDistrict' value='$strValue'> ";
echo "<label for='$strDistrict'>".$row['title']."</label><br>\n";
}
?>
<br>
<input type="hidden" name="csrf" value="<?=$_SESSION['csrf_token']?>">
<input type="submit" class="btn btn-primary" value="Auswahl ändern">
</form>
</div> </div>
</div> <!-- row --> </div> <!-- row -->
</div> </div>

View File

@ -5,7 +5,6 @@
if (!$boolLogin) { if (!$boolLogin) {
header("Location: login.php"); header("Location: login.php");
} }
$dbFilename="../db/locations.db";
require("../config.php"); require("../config.php");
if($_POST['csrf'] !== $_SESSION['csrf_token']) { if($_POST['csrf'] !== $_SESSION['csrf_token']) {

29
admin/district_chk.php Normal file
View File

@ -0,0 +1,29 @@
<?php
session_start();
$strLoginName=(isset($_SESSION['user'])) ? $_SESSION['user'] : "" ;
$boolLogin = (!empty($strLoginName));
if (!$boolLogin) {
header("Location: login.php");
}
require("../config.php");
if($_POST['csrf'] !== $_SESSION['csrf_token']) {
die("Ungültiger Token");
}
$strSQL="SELECT * FROM district";
$result = $db->query($strSQL);
$numCounter=1;
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strDistrict=$row['district'];
if (isset($_POST[$strDistrict])) {
$db->query("UPDATE `district` SET `active`= '1' WHERE `district`='$strDistrict'");
} else {
$db->query("UPDATE `district` SET `active`= '0' WHERE `district`='$strDistrict'");
}
}
header("Location: configuration.php");
//print_r($_POST);
?>

View File

@ -85,7 +85,7 @@
<link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/lightbox.css" /> <link rel="stylesheet" href="css/lightbox.css" />
<title>Ideenmelder</title> <title><?=$strTitle?></title>
</head> </head>
<body> <body>

View File

@ -14,9 +14,6 @@
<link rel="stylesheet" href="css/bootstrap.min.css" /> <link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/style.css" />
<title><?=$strTitle?></title> <title><?=$strTitle?></title>
<script src="js/jquery.min.js"></script> <script src="js/jquery.min.js"></script>
<style> <style>
@ -41,7 +38,7 @@
</form> </form>
</div> </div>
<p style="clear:both";> <p style="clear:both";>
<h3>Kreise und kreisfreie Städte</h3> <h3>Teilnehmende Kreise und kreisfreie Städte</h3>
<div> <div>
<?php <?php
foreach ($arrDistrict as $key => $strTitle):?> foreach ($arrDistrict as $key => $strTitle):?>