-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadd-employee.php
147 lines (120 loc) · 6.78 KB
/
add-employee.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
<!--
//////////////////////////////////////////////////////////////////////////////////////////
//
// Project: BLOOD_BANK - Management System
//
// File: add-employee.php
//
// Version: 1.0
//
// Description:
//
// A Simple Blood Bank Mangement System made in Raw PHP
//
//
//
//
// Author: Ami Bappy [[email protected]]
//
// Github: https://github.com/amibappy
//
//
// .______ .___ .______ .______ ____. .____
// | _ \ / \ | _ \ | _ \ \ \ / /
// | |_) | / ^ \ | |_) | | |_) | \ \/ /
// | _ < / /_\ \ | ___/ | ___/ \_ _/
// | |_) | / _____ \ | | | | | |
// |______/ /__/ \__\ | _| | _| |__|
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2017 Bappy [[email protected]]
// All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////
//
// Unauthorized copying of this file, via any medium is strictly prohibited
// Proprietary and confidential
//
//////////////////////////////////////////////////////////////////////////////////////////
//
// DO NOT REMOVE THIS AREA
//
//////////////////////////////////////////////////////////////////////////////////////////
-->
<?php session_start(); ?>
<?php require_once('header.php')?>
<?php require_once('sidebar.php')?>
<?php
if(!$_SESSION['user'])
{
header('Location: login.php');
}
if(isset($_POST['submit']))
{
add_new_employee();
}
function add_new_employee()
{
if(!empty($_POST['name']) && !empty($_POST['salary']) && !empty($_POST['area']) && !empty($_POST['address']) && !empty($_POST['branch']) && !empty($_POST['role']) && !empty($_POST['phone']) && !empty($_POST['email']))
{
$name = $_POST['name'];
$salary = $_POST['salary'];
$area = $_POST['area'];
$address = $_POST['address'];
$branch = $_POST['branch'];
$role = $_POST['role'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$conn = oci_connect('system', 'admin', 'localhost/XE');
$query = "INSERT INTO admin.employee(emp_id, b_id, emp_name, emp_salary, emp_address, emp_area, emp_role, phone, email) VALUES (admin.empy.nextval, $branch, '$name', '$salary', '$address', '$area', '$role', '$phone', '$email')";
$stid = oci_parse($conn, $query);
$result = oci_execute($stid);
if(!$result) {
echo "Failed !";
}else {
echo "Successfully added New Employee !";
header('Location: employee.php');
}
}else {
echo "<p id=\"warning\">Fill All The Information !</p>";
}
}
?>
<div class="donor-section">
<h1 class="menu-title">Add New Employee: </h1>
<a href="employee.php" class="hlink cat-link">Back to Employee List</a>
<form id="add-donor-form" name="donorform" action="add-employee.php" method="post">
<br>
<p class="form-text">Employee Name : </p>
<input name="name" class="form-field" type="text" placeholder="Name">
<p class="form-text">Salary : </p>
<input name="salary" class="form-field" type="text" placeholder="Salary">
<p class="form-text">Area : </p>
<input name="area" class="form-field" type="text" placeholder="Area">
<p class="form-text">Address : </p>
<textarea name="address" id="textarea" class="form-field" cols="30" rows="10" placeholder="Address"></textarea>
<p id="pcat" class="form-text">Select Branch : </p>
<select name="branch">
<?php
$conn = oci_connect('system', 'admin', 'localhost/XE');
$stid = oci_parse($conn, "SELECT * FROM admin.branch");
oci_execute($stid);
while (($row = oci_fetch_array($stid, OCI_BOTH)) != false) {
echo "<option value=\"".$row['B_ID']."\">".$row['B_NAME']."</option>";
}
?>
</select>
<p class="form-text">Role : </p>
<input name="role" class="form-field" type="text" placeholder="Role">
<p class="form-text">Phone : </p>
<input name="phone" class="form-field" type="text" placeholder="Phone">
<p class="form-text">Email : </p>
<input name="email" class="form-field" type="text" placeholder="Email">
<br>
<input type="submit" name="submit" id="submit" value="Add New Employee" class="form-field">
</form>
</div>
<?php require_once('footer.php')?>