-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.php
More file actions
48 lines (37 loc) · 1.85 KB
/
submit.php
File metadata and controls
48 lines (37 loc) · 1.85 KB
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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once "db-inc.php";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['form_type']) && $_POST['form_type'] === 'employee') {
$employeeNumber = intval($_POST['employeeNumber']);
$firstName = mysqli_real_escape_string($conn, $_POST['firstName']);
$lastName = mysqli_real_escape_string($conn, $_POST['lastName']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$departmentCode = mysqli_real_escape_string($conn, $_POST['departmentCode']);
$jobTitle = mysqli_real_escape_string($conn, $_POST['jobTitle']);
$salary = intval($_POST['salary']);
$sql = "INSERT INTO employees (employeeNumber, firstName, lastName, email, departmentCode, jobTitle, salary)
VALUES ($employeeNumber, '$firstName', '$lastName', '$email', '$departmentCode', '$jobTitle', $salary)";
if (mysqli_query($conn, $sql)) {
header("Location: index.php?success=employee");
exit;
} else {
echo "Error inserting employee: " . mysqli_error($conn);
}
} elseif (isset($_POST['form_type']) && $_POST['form_type'] === 'interview') {
$departmentCode = mysqli_real_escape_string($conn, $_POST['departmentCode']);
$role = mysqli_real_escape_string($conn, $_POST['role']);
$status = mysqli_real_escape_string($conn, $_POST['status']);
$sql = "INSERT INTO interviews (departmentCode, role, status)
VALUES ('$departmentCode', '$role', '$status')";
if (mysqli_query($conn, $sql)) {
header("Location: index.php?success=interview");
exit;
} else {
echo "Error inserting interview: " . mysqli_error($conn);
}
}
}
mysqli_close($conn);
?>