This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdriver_rem.php
57 lines (53 loc) · 1.53 KB
/
driver_rem.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
54
55
56
57
<? if(!defined("CONFIG")) exit(); ?>
<? if(!isset($login)) { show_error("You do not have administrator rights\n"); return; } ?>
<?
$id = addslashes($_GET['id']);
require_once("functions.php"); // import mysql function
$link = mysqlconnect(); // call mysql function to get the link to the database
$query = "SELECT * FROM driver WHERE id='$id'";
$result = mysqli_query($link,$query);
if(!$result) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
if(mysqli_num_rows($result) == 0){
show_error("Driver does not exist\n");
return;
}
$item = mysqli_fetch_array($result);
$tquery = "SELECT t.name FROM team_driver td JOIN team t ON (td.team = t.id) WHERE driver='$id'";
$tresult = mysqli_query($link,$tquery);
if(!$tresult) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
if(mysqli_num_rows($tresult) > 0) {
$teams = "";
while($t = mysqli_fetch_array($tresult)) {
$teams .= "• " . $t['name'] . "\n";
}
show_error("Driver cannot be deleted because it is related to the following team(s):\n" . $teams);
return;
}
?>
<h1>Delete driver</h1>
<form action="driver_rem_do.php" method="post">
<table border="0">
<tr>
<td width="120">Name:</td>
<td><?=$item['name']?></td>
</tr>
<tr>
<td> </td>
<td>Are you sure that you want to delete this driver?</td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" name="id" value="<?=$id?>">
<input type="submit" class="button submit" value="Yes">
<input type="button" class="button cancel" value="No" onclick="history.go(-1);">
</td>
</tr>
</table>
</form>