add teams to teams table and fix for login
This commit is contained in:
39
app/public/add_team.php
Normal file
39
app/public/add_team.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
session_start();
|
||||
include("../scripts/connection.php");
|
||||
include("../scripts/functions.php");
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
write_team($con, $_POST['team_name'], $_POST['fire_department']);
|
||||
header("Location: mannschaft.php");
|
||||
die;
|
||||
}
|
||||
|
||||
echo file_get_contents("html/header.html");
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div class="headline">
|
||||
<h2>Mannschaft hinzufügen</h2>
|
||||
</div>
|
||||
<div>
|
||||
<form method="post">
|
||||
<label for="team_name">Mannschaftsname</label>
|
||||
<input type="text" name="team_name"/><br>
|
||||
<label for="fire_department">Feuerwehr</label>
|
||||
<input type="text" name="fire_department" list="fire_departments"/><br>
|
||||
<datalist id="fire_departments">
|
||||
<?php
|
||||
load_fire_departments($con);
|
||||
?>
|
||||
</datalist>
|
||||
<input id="button" type="submit" value="Hinzufügen">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<?php
|
||||
$con = null;
|
||||
echo file_get_contents("html/footer.html");
|
||||
?>
|
||||
@@ -9,14 +9,19 @@
|
||||
|
||||
if(!empty($user_name) && !empty($password)) {
|
||||
$user_data = get_user_data_name($con, $user_name);
|
||||
$phash = generate_password_hash($password, $user_data['salt']);
|
||||
if($user_data['password'] === $phash) {
|
||||
$_SESSION['user_id'] = $user_data['user_id'];
|
||||
header("Location: index.php");
|
||||
die;
|
||||
if($user_data) {
|
||||
$phash = generate_password_hash($password, $user_data['salt']);
|
||||
if($user_data['password'] === $phash) {
|
||||
$_SESSION['user_id'] = $user_data['user_id'];
|
||||
header("Location: index.php");
|
||||
die;
|
||||
} else {
|
||||
echo "Benutzername oder Passwort stimmen nicht";
|
||||
}
|
||||
} else {
|
||||
echo "Benutzername oder Passwort stimmen nicht";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "Gib bitte gültige Daten ein!";
|
||||
}
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div class="headline">
|
||||
<h2>Mannschaftsverwaltung</h2>
|
||||
</div>
|
||||
<div>
|
||||
<form action="add_team.php" method="get">
|
||||
<input id="butto" type="submit" value="Mannschaft hinzufügen">
|
||||
</form>
|
||||
</div>
|
||||
<div class="table-div">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -166,3 +166,24 @@ function write_station($con, $station_name, $station_pos) {
|
||||
handle_pdo_exceptio($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_fire_departments($con) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT DISTINCT feuerwehr FROM Mannschaft");
|
||||
$stmt->execute();
|
||||
return $stmt;
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function write_team($con, $team_name, $fire_department) {
|
||||
try {
|
||||
$stmt = $con->prepare("INSERT INTO Mannschaft (name, feuerwehr) VALUES (?, ?)");
|
||||
$stmt->bindParam(1, $team_name, PDO::PARAM_STR);
|
||||
$stmt->bindParam(2, $fire_department, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
} catch(PDOEXCEPTION $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
@@ -118,3 +118,10 @@ function load_teams_no_points($con, $s_id) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function load_fire_departments($con) {
|
||||
$stmt = get_fire_departments($con);
|
||||
foreach($stmt->fetchAll() as $option) {
|
||||
echo "<option>".$option['feuerwehr']."</option>\n";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user