This repository has been archived by the owner on Sep 5, 2021. It is now read-only.
forked from avs-code/PREM-Podium-race-E-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseason_chg_do.php
53 lines (41 loc) · 1.81 KB
/
season_chg_do.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?
require_once("session_start.php");
if(!isset($login)) error("You do not have administrator rights\n");
$id = addslashes($_POST['id']);
$name = htmlspecialchars($_POST['name']);
$division = addslashes($_POST['division']);
$ruleset = addslashes($_POST['ruleset']);
$ruleset_qualifying = addslashes($_POST['ruleset_qualifying']);
$team = $_POST['team'];
$maxteams = addslashes($_POST['maxteams']);
$error = "";
if(empty($name)) $error .= "You must fill in a name\n";
if(!empty($error)) error($error);
$msg = "";
require_once("functions.php"); // import mysql function
$link = mysqlconnect(); // call mysql function to get the link to the database
$query = "SELECT * FROM season WHERE name = '$name' AND division = '$division' AND id != '$id'";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
if(mysqli_num_rows($result) > 0) error("Season with the same name and division does already exist\n");
$query = "UPDATE season SET name='$name', division='$division', ruleset='$ruleset', ruleset_qualifying='$ruleset_qualifying', maxteams='$maxteams' WHERE id='$id'";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
$query = "DELETE FROM season_team WHERE season='$id'";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
if(is_array($team)) {
foreach($team as $t) {
if(empty($t)) continue;
$t = addslashes($t);
$values .= "('$id', '$t'), ";
}
$values = substr($values, 0, -2); //laatste 2 tekens strippen
if(!empty($values)) {
$query = "INSERT INTO season_team (season, team) VALUES $values";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
}
}
return_do(".?page=seasons", "Season succesfully modified\n$msg");
?>