-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStaff_Entry.php
150 lines (137 loc) · 3.38 KB
/
Staff_Entry.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
session_start();
include('connect.php');
if(isset($_POST['btnSave']))
{
$txtStaffName=$_POST['txtStaffName'];
$cboRoleID=$_POST['cboRoleID'];
$txtEmail=$_POST['txtEmail'];
$txtPassword=$_POST['txtPassword'];
$txtPhone=$_POST['txtPhone'];
$txtAddress=$_POST['txtAddress'];
//Image Upload-------------------------------------------------------
$fileStaffPhoto=$_FILES['fileStaffPhoto']['name']; //Alex.jpg
$FolderName="StaffPhoto/"; //StaffPhoto/
$FileName=$FolderName . '_' . $fileStaffPhoto; //StaffPhoto/_Alex.jpg
$copied=copy($_FILES['fileStaffPhoto']['tmp_name'], $FileName);
if(!$copied)
{
echo "<p>Staff Photo Cannot Upload!</p>";
exit();
}
//Check Validation : Email Already exist-----------------------------
$Check="SELECT * FROM staff WHERE Email='$txtEmail' ";
$result=mysqli_query($connection,$Check);
$count=mysqli_num_rows($result);
if($count > 0)
{
echo "<script>window.alert('Email Address Already Exist!')</script>";
echo "<script>window.location='Staff_Entry.php'</script>";
}
else
{
$Insert="INSERT INTO staff
(StaffName,RoleID,Email,Password,Phone,Address,StaffPhoto)
VALUES
('$txtStaffName','$cboRoleID','$txtEmail','$txtPassword','$txtPhone','$txtAddress','$FileName')
";
$result=mysqli_query($connection,$Insert);
}
if($result)
{
echo "<script>window.alert('Successfully Saved!')</script>";
echo "<script>window.location='Staff_Entry.php'</script>";
}
else
{
echo "<p>Something went wrong in Staff Entry : " . mysqli_error($connection) . "</p>";
}
//------------------------------------------------------------------
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Staff Entry</title>
</head>
<body>
<form action="Staff_Entry.php" method="post" enctype="multipart/form-data">
<script>
$(document).ready
( function ()
{
$('#tableid').DataTable();
}
);
</script>
<fieldset>
<legend>Staff Entry :</legend>
<table cellpadding="5px" align="center">
<tr>
<td>Staff Name :</td>
<td>
<input type="text" name="txtStaffName" placeholder="Eg. Alan Smith" required />
</td>
</tr>
<tr>
<td>Role :</td>
<td>
<select name="cboRoleID">
<option>--Choose Role--</option>
<?php
$RoleData="SELECT * FROM Role";
$result=mysqli_query($connection,$RoleData);
$count=mysqli_num_rows($result);
for($i=0;$i<$count;$i++)
{
$row=mysqli_fetch_array($result);
$RoleID=$row['RoleID'];
$RoleName=$row['RoleName'];
echo "<option value='$RoleID'>$RoleID - $RoleName</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Email :</td>
<td>
<input type="email" name="txtEmail" placeholder="[email protected]" required />
</td>
</tr>
<tr>
<td>Password :</td>
<td>
<input type="password" name="txtPassword" placeholder="XXXXXXXXXXXXXX" required />
</td>
</tr>
<tr>
<td>Phone :</td>
<td>
<input type="text" name="txtPhone" placeholder="+95-----------" required />
</td>
</tr>
<tr>
<td>Staff Photo :</td>
<td>
<input type="file" name="fileStaffPhoto" required />
</td>
</tr>
<tr>
<td>Address :</td>
<td>
<textarea name="txtAddress" placeholder="Enter Address"></textarea>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="btnSave" value="Save" />
<input type="reset" name="btnClear" value="Clear" />
</td>
</tr>
</table>
<hr/>
</form>
</body>
</html>