-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_freezer.php
47 lines (42 loc) · 1.2 KB
/
add_freezer.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
<?php
include 'connect.php';
include 'check_injection.php';
// User
session_start();
if (empty($_SESSION['UserID'])) {
header('Location: login.php?error=login');
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$link = connect();
$clean = check_injection($link, $_POST);
if (empty($_POST["model"])) {
dconnect($link);
header("Location: form_freezer.php?error=invalid&item=model");
exit;
} else {
$model= $_POST["model"];
}
if (empty($_SESSION['UserLabID'])) { // replace with session lab id
dconnect($link);
header("Location: index.php?error=laboratory");
exit;
}else {
$LabID = $_SESSION['UserLabID'];
}
$sql = "INSERT INTO `freezer` (`FModel`, `FLabID`) VALUES ('$model', $LabID)";
if (mysqli_query($link, $sql)) {
dconnect($link);
header("Location: form_freezer.php?success=added&item=Freezer");
exit;
} else {
dconnect($link);
header("Location: form_freezer.php?mysqli_error($link)");
exit;
}
} else {
dconnect($link);
header("Location: form_freezer.php");
exit;
}
?>