Compare commits

...

8 Commits

6 changed files with 24 additions and 5 deletions

View File

@@ -49,7 +49,7 @@
<body>
<div class="center">
<div class="headline">
<h2>Ergebniss eintragen</h2>
<h2>Ergebnis eintragen</h2>
</div>
<div class="form_div">
<form action="" method="post">

View File

@@ -6,8 +6,11 @@
if($_SERVER['REQUEST_METHOD'] == "POST") {
try {
$selected_user_id = get_id_user_by_user_id($con, $_SESSION['user_id']);
if($selected_user_id != $_POST['id']) {
$stmt = $con->prepare("DELETE FROM users WHERE id = :id");
$stmt->execute(['id' => $_POST['id']]);
}
} catch(PDOException $e) {
handle_pdo_exception($e);
}

View File

@@ -9,7 +9,8 @@
$table = $_GET['table'];
}
header('Content-type: text/csv');
ob_start('ob_gzhandler'); #compressing data which is sent to the browser, the browser will decompress the data automatically
header('Content-type: text/csv; charset="UTF-8" ');
header('Content-Disposition: attachment; filename="table.csv" ');
function download_table($stmt) {

View File

@@ -49,7 +49,7 @@
<body>
<div class="center">
<div class="headline">
<h2>Ergebniss bearbeiten</h2>
<h2>Ergebnis bearbeiten</h2>
</div>
<div class="form_div">
<form method="post">

View File

@@ -530,3 +530,15 @@ function get_result_team_station($con, $s_id, $m_id) {
handle_pdo_exception($e);
}
}
function get_id_user_by_user_id($con, $user_id) {
try {
$stmt = $con->prepare("SELECT * FROM users WHERE user_id = ?");
$stmt->bindParam(1, $user_id, PDO::PARAM_STR);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt->fetch()['id'];
} catch( PDOException $e) {
handle_pdo_exception($e);
}
}

View File

@@ -235,6 +235,9 @@ function update_points($con, $s_id) {
$factor = $results[0]['erg']/ 15.0;
foreach($results as $row) {
$points = round($row['erg']/$factor);
if ($points == 0 && $row['erg'] != 0) {
$points = 1;
}
change_points($con, $row['m_id'], $s_id, $points);
}
}