forked from nisiya/MaristIDCP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
167 lines (149 loc) · 7.04 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
<!--Initial landing page for IDCP. User has to login-->
<!DOCTYPE html>
<html lang="en">
<?php
# Connect to MySQL server and the database
require( 'includes/connect_db_c9.php' ) ;
$invalid = false;
$logout = false;
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$user_id = "";
$user_pwd = "";
if (isset($_GET['logout'])) {
$logout = true;
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['user_id']) and isset($_POST['user_pwd']) ) {
$user_id = $_POST['user_id'];
$user_pwd = SHA1($_POST['user_pwd']);
$query = "SELECT * FROM IDCP_USER WHERE USER_ID='".$user_id."' AND USER_PWD='".$user_pwd."'";
$result = mysqli_query($dbc,$query);
if(mysqli_num_rows( $result ) != 0 ){
session_start();
$userData = mysqli_fetch_array($result, MYSQLI_ASSOC) ; #stores data as array w/ column names as index
$_SESSION['user_id'] = $userData['USER_ID'];
$_SESSION['user_role'] = $userData['USER_ROLE'];
$page = 'home.php?login=true';
header("Location: $page");
} else {
$invalid = true;
}
}
}
?>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>IDCP - Login</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom CSS -->
<!--<link href="css/simple-sidebar.css" rel="stylesheet">-->
<link href="css/sb-admin.css" rel="stylesheet">
<link href="css/banner.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="https://my.marist.edu/myMarist62-theme/images/favicon.ico"/>
</head>
<body>
<img src='placeholder.png' style="visibility: hidden;" id="banner">
<!--Navigation Bars-->
<div id="wrapper">
<!--<img src="IDCPorig.png" id="banner">-->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<img src="IDCPlogo.PNG" id="banner">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand"></a>
</div>
<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav side-nav" style="margin-top:7%;">
<li>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</nav>
<?php
if($invalid){
?>
<div class="alert alert-danger alert-dismissible" role="alert" style="margin-top: 20px">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error!</strong> Incorrect username or password
</div>
<?php
}
else if($logout){?>
<div class="alert alert-success alert-dismissible" role="alert" style="margin-top: 20px">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Goodbye!</strong> You have successfully logged out
</div>
<?php
}
?>
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="dropdown">
<!-- <div class="alert alert-danger alert-dismissible" role="alert" style="margin-top: 20px; display='none'">-->
<!-- <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>-->
<!-- <strong>Error</strong> Wrong username or password-->
<!--</div>-->
<div class="page-header">
<h1> Welcome, Please Login to continue </h1>
</div>
<form action="index.php" method="POST" class="form-horizontal" data-toggle="validator" id="user_login">
<div class="form-group">
<label class="col-xs-3 control-label"></label>
<div class="col-xs-5">
<h3>User Login</h3>
<p id="ErrorMsg"></p>
</div>
</div>
<div class="form-group">
<label class="col-xs-3 control-label">ID*</label>
<div class="col-xs-2">
<input type="text" class="form-control" name="user_id" data-error="Please enter a user ID" required>
</div>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="col-xs-3 control-label">Password*</label>
<div class="col-xs-2">
<input type="password" class="form-control" name="user_pwd" data-error="Please enter a password" required>
</div>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<div class="col-xs-5 col-xs-offset-3">
<button type="submit" class="btn btn-default">Login</button>
</div>
</div>
</form>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!--Footer-->
<?php require('includes/footer.php'); ?>
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Validator Bootstrap Plugin-->
<script src="js/validator.js"></script>
</body>
</html>