This repository was archived by the owner on Nov 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakeEmployee.php
More file actions
97 lines (82 loc) · 2.63 KB
/
Copy pathmakeEmployee.php
File metadata and controls
97 lines (82 loc) · 2.63 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php session_start(); ?>
<html>
<head>
<title>Make Employee</title>
</head>
<body>
Logged in as: <?php echo $_SESSION['Username'];
//This gets the username from the session cookie?> | <a href="logout.php">Log out</a> |
<a href="homepage.php">Homepage</a>
<?php if (isset($_SESSION['Admin'])) {
echo "| <a href=\"adminconsole.php\">Admin Console</a>";
} //Checks if Admin. if you are, adds link to console?> <br>
<form method="post">
<p>
<label for="empID">Employee ID:</label>
<br>
<input type="text" id="empID" name="empID"/>
<br>
<label for="name">Name:</label>
<br>
<input type="text" id="name" name="name"/>
<br>
<label for="email">Email:</label>
<br>
<input type="email" id="email" name="email"/>
<br>
<label for="password">Password:</label>
<br>
<input type="text" id="password" name="password"/>
<br>
<label for="cell">Cellphone #:</label>
<br>
<input type="tel" id="cell" name="cell">
<br>
<label for="address">Address:</label>
<br>
<input type="text" id="address" name="address"/>
<br>
<label for="admin">Admin:</label>
<br>
<select id="admin" name="admin">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
<br>
</p>
<p>
<input type="submit" value="Submit" name="Submit">
</p>
</form>
</body>
</html>
<?php
/**
* Created by PhpStorm.
* User: ccerr
* Date: 2018-11-03
* Time: 8:58 PM
*/
if (!isset($_SESSION['Admin'])) {
header('Location:restricted.php');
}
$host = "localhost";
$user = "root";
$password = "";
$dbName = "proj_db";
$connect = mysqli_connect($host, $user, $password, $dbName)
or die("Connection Failed");
if (!empty($_POST['name'])) {
$EmpID = $_POST['empID'];
$Name = $_POST['name'];
$Email = $_POST['email'];
$UserPass = $_POST['password'];
$Cell = $_POST['cell'];
$Address = $_POST['address'];
$Admin = $_POST['admin'];
$query = "INSERT INTO user_info VALUES('$EmpID','$Name','$Email',null ,'$UserPass','$Cell','$Address','$Admin')";
$result = mysqli_query($connect, $query);
if ($result) {
header('Location:displayUsers.php?employeeCreated=1');
} else echo "Insert Failed";
}