-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin.php
114 lines (93 loc) · 3.23 KB
/
admin.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
<?php
include "head.php";
session_start();
if(!isset($_SESSION['Eid']))
header('location:home.php');
$Eid = $_SESSION['Eid'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "supermarket";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<h1><center>Employees under you</center></h1>";
$sql = "SELECT * FROM employee natural join employee_contacts where Supervisor_ID = $Eid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class = 'table table-hover table-striped'><tr><th>Employee ID</th><th>Employee Name</th><th>Employee Contact</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["Employee_ID"]. "</td><td>" . $row["Employee_Name"]. "</td><td>" . $row["Contact"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
if(isset($_POST['button2']))
{
$num = $_POST['number'];
if(strlen($num) < 10)
{
echo "Phone number must be 10 digits";
}
else
{
$con = mysqli_connect("127.0.0.1","root","");
mysqli_select_db($con, "supermarket");
$q = "select * from employee_contacts where Employee_ID = $Eid and Contact = $num";
$result = mysqli_query($con, $q);
$n = mysqli_num_rows($result);
if($n != 0)
{
echo "Number exists!!";
}
else
{
$q = "INSERT INTO `employee_contacts` VALUES ($Eid, $num)";
// echo $q
}
if(mysqli_query($con, $q))
{
echo "Item Added Successfully!!";
header('location:admin.php');
}
else
{
echo "Item cannot be added!! Check Details entered";
}
}
}
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<h1><center><br>Your contact details</center></h1>";
$sql = "SELECT * FROM employee natural join employee_contacts where Employee_ID = $Eid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class = 'table table-hover table-striped'><tr><th>Employee ID</th><th>Employee Address</th><th>Employee Contact</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["Employee_ID"]. "</td><td>" . $row["Home_Number"].$row["Street"].$row["Pincode"]. "</td><td>" . $row["Contact"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
?>
<br>
<br>
<div class = "container-fluid row padding">
<div class="col-lg-3 col-md-6 col-sm-6" >
<h1 style = "padding-left: 20%"><br>Add Phone Number : </h1>
</div>
<div class="col-lg-9 col-md-6 col-sm-6" >
<form method="post">
<label>Number</label>
<br>
<input type="varchar" name="number" required>
<br><br>
<input type="submit" name="button2" value = "Add">
</form>
</div>
</div>