-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver_add_do.php
38 lines (30 loc) · 1.25 KB
/
driver_add_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
<?php
/*
* driver_add_do.php Version 1.11.0.0
* date 05.05.19
*
*
*/
require_once("session_start.php");
if(!isset($login)) error("Du hast keine Administratorrechte");
require_once("functions.php"); // import mysql function
$link = mysqlconnect(); // call mysql function to get the link to the database
$name = htmlspecialchars($_POST['name']);
$country = htmlspecialchars($_POST['country']);
$plate = htmlspecialchars($_POST['plate']);
$error = "";
if(empty($name)) $error .= "You must fill in a name\n";
if(empty($country)) $error .= "You must define drivers nationality\n";
if(empty($plate)) $error .= "You must define drivers car-number\n";
if(!empty($error)) error($error);
$msg = "";
$photo = htmlspecialchars($_POST['driver_photo']);
$query = "SELECT * FROM driver WHERE name = '$name'";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
if(mysqli_num_rows($result) > 0) error("Driver name is already in use\n");
$query = "INSERT INTO driver (name, plate, country, driver_photo) VALUES ('$name', '$plate', '$country','$photo')";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
return_do("liga.php?page=drivers", "Driver succesfully added . $msg");
?>