-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
116 lines (114 loc) · 4 KB
/
index.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
<?php
session_start();
include("db_connect.php");
if(isset($_POST["submit"])){
$u = $_POST["username"];
$p = $_POST["password"];
$position = $_POST["position"];
if($position != ""){
if($position == "Admin"){
$results = mysqli_query($con, "SELECT username FROM admin WHERE username = '$u' AND password = '$p'");
$count = mysqli_num_rows($results);
if($count == 1){
$_SESSION["username"] = $u;
header("Location:admin.php");
}
else{
echo '<script language="javascript">';
echo 'alert("No such user is found.")';
echo '</script>';
}
}
if($position == "Pharmacist"){
$results = mysqli_query($con, "SELECT username FROM pharmacist WHERE username = '$u' AND password = '$p'");
$count = mysqli_num_rows($results);
if($count == 1){
$_SESSION["username"] = $u;
header("Location:pharmacist.php");
}
else{
echo '<script language="javascript">';
echo 'alert("No such user is found.")';
echo '</script>';
}
}
if($position == "Cashier"){
$results = mysqli_query($con, "SELECT username FROM cashier WHERE username = '$u' AND password = '$p'");
$count = mysqli_num_rows($results);
if($count == 1){
$_SESSION["username"] = $u;
header("Location:cashier.php");
}
else{
echo '<script language="javascript">';
echo 'alert("No such user is found.")';
echo '</script>';
}
}
}else{
echo "Please login with correct credentials ";
}
}
?>
<html>
<head>
<title>Login Page</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;700&display=swap" rel="stylesheet">
<style>
*{
box-sizing: border-box;
font-family: "manrope","sans-serif";
}
body{
display: flex;
justify-content: center;
align-items: center;
padding-top: 100px;
background-color: #f2f2f2;
}
form{
width: 30%;
height: 30%;
background-color: white;
display: flex;
flex-direction: column;
justify-content: center;
padding: 1%;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
form *:not(h1){
margin-top: 5%;
padding: 3%;
border: 2px solid rgba(0,0,0,0.1);
border-radius: 20px;
background-color: white;
}
[name="submit"]{
border-color: #3498db;
background-color: #3498db;
color: white;
cursor:pointer;
}
h1{
text-align: center;
font-weight: bold;
}
</style>
</head>
<body>
<form action = "index.php" method = "post">
<h1>Login</h1>
<select name="position">
<option>Pharmacist</option>
<option>Admin</option>
<option>Cashier</option>
</select>
<input type="text" name="username" placeholder="Username">
<input type="password" name="password" placeholder="Password">
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>