-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
132 lines (89 loc) · 3.73 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
<?php
header("X-XSS-Protection: 1; mode=block");
session_start();
error_reporting(0);
$uname = $_POST['uname'];
$pass = $_POST['pass'];
// Create connection
/*$conn = mysqli_connect('localhost', 'root', '','infosec');
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}*/
$db_connection = mysqli_connect("localhost", "root", "", "hostel_query_management_system");
$username = htmlspecialchars(strip_tags(mysqli_real_escape_string($db_connection, $uname)));
$password = htmlspecialchars(strip_tags(mysqli_real_escape_string($db_connection, $pass)));
$query = "SELECT * FROM details WHERE username = '" . $username. "' AND password = '" . $password . "'";
//$sql="SELECT * FROM details where username='$uname' AND password='$pass' ";
$result = mysqli_query($db_connection,$query);
$row = mysqli_fetch_array($result);
if(is_array($row)) {
$_SESSION["username"] = $row['username'];
$_SESSION["permission"] = $row['permission'];
}
else {
$msg = "Invalid Username or Password!";
}
if(isset($_SESSION["username"])) {
header("Location:report.php");
}
/*if(isset($check)){
$msg = 'Login Complete! Thanks';
echo "<script> window.location.assign('Online_BI_Report.php'); </script>";
}
else{
$msg = 'Login Failed!<br /> Please make sure that you enter the correct details and that you have activated your account.';
}
*/
?>
<html>
<head>
<title>Hostel Query Management System</title>
<link rel = "icon" href="pictures/favicon.png"
type = "image/x-icon">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
<style>
body {
background-image:url(pictures/full-0.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
.container{
text-align: center;
margin-top: 200px;
width: 350px;
}
.margin{
margin-top: 20px;
}
.centre{
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<strong><h1>Login Gateway</h1></strong>
<form method="post" class="margin" autocomplete="off">
<fieldset class="form-group">
<label for="uname"><strong>Enter the UserName</strong></label>
<input type="text" class="form-control centre" id="city" name="uname" value = "<?php if (array_key_exists('uname', $_POST)) {
echo $_POST['uname'];
}
?>">
<label for="pass"><strong>Enter the Password</strong></label>
<input type="password" class="form-control centre" id="city" name="pass" value = "<?php if (array_key_exists('pass', $_POST)) {
echo $_POST['pass'];
}
?>">
</fieldset>
<button type="submit" class="btn btn-tertiary"><strong>Submit</strong></button>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
</body>
</html>