add stations
This commit is contained in:
@@ -17,15 +17,10 @@
|
||||
header("Location: statistik.php");
|
||||
die;
|
||||
}
|
||||
|
||||
echo file_get_contents("html/header.html");
|
||||
?>
|
||||
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Eintrag eintragen</title>
|
||||
</head>
|
||||
<body>
|
||||
<div <?php if(!station_exists($con, $_GET['station'])) { echo "hidden=\"true\"";}?>>
|
||||
<form action="" method="post">
|
||||
@@ -52,4 +47,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
$con = null;
|
||||
echo file_get_contents("html/footer.html");
|
||||
?>
|
||||
32
app/public/add_station.php
Normal file
32
app/public/add_station.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
session_start();
|
||||
include("../scripts/connection.php");
|
||||
include("../scripts/functions.php");
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
write_station($con, $_POST['station_name'], $_POST['station_pos']);
|
||||
header("Location: stationen.php");
|
||||
die;
|
||||
}
|
||||
|
||||
echo file_get_contents("html/header.html");
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div class="headline">
|
||||
<h2>Station hinzufügen</h2>
|
||||
</div>
|
||||
<div>
|
||||
<form method="post">
|
||||
<label for="station_name">Name:</label>
|
||||
<input id="station_name" type="text" name="station_name"/><br>
|
||||
<label for="station_pos">Standort:</label>
|
||||
<input id="station_pos" type="text" name="station_pos"/><br>
|
||||
<input id="button" type="submit" value="Hinzufügen"/>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
<?php
|
||||
$con = null;
|
||||
echo file_get_contents("html/footer.html");
|
||||
?>
|
||||
@@ -9,6 +9,14 @@
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div class="headline">
|
||||
<h2>Stationen</h2>
|
||||
</div>
|
||||
<div>
|
||||
<form action="add_station.php" method="get">
|
||||
<input type="submit" value="Station anlegen"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="table-div">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -9,19 +9,29 @@
|
||||
$_SESSION['select-statistics'] = $_GET['stationen'];
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['select-statistics']) || $_SESSION['select-statistics'] == "total-score") {
|
||||
$session = "total-score";
|
||||
} else {
|
||||
$session = $_SESSION['select-statistics'];
|
||||
}
|
||||
|
||||
echo file_get_contents("html/header.html");
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div class="headline">
|
||||
<?php
|
||||
if($session == "total-score") {
|
||||
echo "<h2>Gesamtpunkte</h2\n";
|
||||
} else {
|
||||
echo "<h2>" . get_station_name($con, $session)['name'] . "</h2>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div>
|
||||
<form name="switch-statistics" method="get">
|
||||
<select name="stationen" id="station" onchange="this.form.submit()">
|
||||
<?php
|
||||
if(!isset($_SESSION['select-statistics']) || $_SESSION['select-statistics'] == "total-score") {
|
||||
$session = "total-score";
|
||||
} else {
|
||||
$session = $_SESSION['select-statistics'];
|
||||
}
|
||||
load_options_stations($con, $session);
|
||||
?>
|
||||
</select>
|
||||
@@ -36,15 +46,6 @@
|
||||
|
||||
?>
|
||||
</div>
|
||||
<div class="headline">
|
||||
<?php
|
||||
if($session == "total-score") {
|
||||
echo "<h2>Gesamtpunkte</h2\n";
|
||||
} else {
|
||||
echo "<h2>" . get_station_name($con, $session)['name'] . "</h2>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="table-div">
|
||||
<table>
|
||||
<?php
|
||||
|
||||
@@ -154,4 +154,15 @@ function write_points($con, $s_id, $m_id, $points, $time) {
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function write_station($con, $station_name, $station_pos) {
|
||||
try {
|
||||
$stmt = $con->prepare("INSERT INTO Station (name, standort) VALUES (?, ?)");
|
||||
$stmt->bindParam(1, $station_name, PDO::PARAM_STR);
|
||||
$stmt->bindParam(2, $station_pos, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exceptio($e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user