-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
187 lines (156 loc) · 4.37 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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<html>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="/main.js" defer></script>
<title>ADMIN</title>
<link href="style.css" rel="stylesheet" />
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: white;
}
main{
margin-right: 20%;
}
.login-container {
width: 300px;
margin: 100px auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
font-weight: bold;
}
.form-group input {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.form-group input:focus {
outline: none;
border-color: #007bff;
}
.form-group button {
width: 100%;
padding: 10px;
background-color: #234;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.form-group button:hover {
background-color:lightblue;
}
.alert-container {
position: absolute;
top: 88%;
width: 100%;
display: flex;
justify-content: center;
z-index: 1;
margin-left: 11%;
}
.alert {
padding: 15px;
margin-bottom: 20px;
border-radius: 4px;
font-size: 16px;
max-width: 400px;
background-color: #dff0d8;
border: 1px solid #d6e9c6;
color: #3c763d;
text-align: center;
}
.alert-error {
background-color: #f2dede;
border-color: #ebccd1;
color: #a94442;
}
</style>
</head>
<body>
<a href="index.php">
<img src="KCT1.jpeg" alt="" height=90px>
</a>
<header>PLACEMENT MANGEMENT SYSTEM</header>
<nav>
<ul class="nav-list">
<li class="active">
<a href="index.php" aria-current="page">ADMIN</a>
</li>
<li>
<a href="PC.php">PLACEMENT CELL</a>
</li>
<li>
<a href="PCS.php">PLACEMENT COORDINATOR</a>
</li>
</ul>
</nav>
<main><div class="login-container">
<h2>Login</h2>
<form method="POST" name="myform4">
<div class="form-group">
<label>Username:</label>
<input type="text" id="username" name="email" required="">
</div>
<div class="form-group">
<label>Password:</label>
<input type="password" id="password" name="pass" required="">
</div>
<div class="form-group">
<button type="submit" name="submit">Login</button>
</div>
</form>
</div></main>
<?php
// Database connection parameters
$servername = "localhost";
$username = "root";
$password = "";
$database = "pms";
session_start();
// Create connection
$mysqli = new mysqli($servername, $username, $password, $database);
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve username and password from form
$username = $_POST['email'];
$password = $_POST['pass'];
// Prepare SQL statement to select user from database
$sql = "SELECT * FROM adminlogin WHERE adminid='$username' AND adminpass='$password'";
$result = $mysqli->query($sql);
if ($result->num_rows == 1) {
// User exists, login successful
// Perform further actions like redirecting to another page
header("Location: $path adminpage.php");
} else {
// Invalid username or password
echo "<div class='alert-container'><div class='alert alert-error'>Error: Username or password is incorrect</div></div>";
}
}
// Close connection
$mysqli->close();
// Close the database connection
?>
</body>
</html>