-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminCreateStaffSQL.php
More file actions
41 lines (29 loc) · 1.04 KB
/
adminCreateStaffSQL.php
File metadata and controls
41 lines (29 loc) · 1.04 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
<?php
session_start();
require_once('php/db_functions/db_connect.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$phoneNumber = $_POST['phoneNumber'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$staffRole = $_POST['staffRole'];
$salary = $_POST['salary'];
$hireDate = $_POST['hireDate'];
$department_id = $_POST['department_id'];
$staffPassword = ($_POST['password']);
$hashed_password = password_hash($staffPassword, PASSWORD_DEFAULT);
$conn = makeConnection();
$created = false;
$stmt = $conn->prepare("INSERT INTO staff (firstName, lastName, phoneNumber, email, gender, staffRole, salary, hireDate, department_id, staffPassword) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('ssssssdsis', $firstName, $lastName, $phoneNumber, $email, $gender, $staffRole, $salary, $hireDate, $department_id, $hashed_password);
$stmt->execute();
//the logic
if ($stmt) {
$created = true;
}
$stmt->close();
$conn->close();
header('Location: adminDashboard.php');
exit;
}