-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
159 lines (122 loc) · 4.18 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
<?php
if(isset($_POST['login']))
{
//start of try block
try{
//checking empty fields
if(empty($_POST['user_name'])){
throw new Exception("UserID is required!");
}
if(empty($_POST['password'])){
throw new Exception("Password is required!");
}
//establishing connection with db and things
include ('connect.php');
//checking login info into database
// prepare the query
// prepare the query
$stmt = mysqli_prepare($conn, "SELECT * FROM users WHERE user_name=? AND password=? AND user_type=?");
// bind the values to the placeholders
mysqli_stmt_bind_param($stmt, "sss", $_POST['user_name'], $_POST['password'], $_POST['user_type']);
// execute the query
mysqli_stmt_execute($stmt);
// get the result
$result = mysqli_stmt_get_result($stmt);
// check if there is at least one row in the result set
if(mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
// check the user type and redirect accordingly
if($_POST["user_type"] == 'mentor'){
session_start();
$_SESSION['user_name']="oasis";
header('location: teacher/index.php');
}
else if($_POST["user_type"] == 'mentee'){
session_start();
$_SESSION['user_name']="oasis";
header('location: student/nav.php');
}
else if($_POST["user_type"] == 'admin'){
session_start();
$_SESSION['user_name']="oasis";
header('location: admin/index.php');
}
}
else {
header('location: student/result.php');
return;
}
}
//end of try block
catch(Exception $e){
$error_msg=$e->getMessage();
}
//end of try-catch
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Online Mentoring Management System</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >
<link rel="stylesheet" href="styles.css" >
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<center>
<header>
<img src = "img\christ.jpg" style = "width : 500px; length: 500px">
<h1>Online Mentoring Management System</h1>
</header>
<h1>Login</h1>
<?php
//printing error message
if(isset($error_msg))
{
echo $error_msg;
}
?>
<div class="content">
<div class="row">
<form method="post" class="form-horizontal col-md-6 col-md-offset-3">
<div class="form-group">
<label for="input1" class="col-sm-3 control-label">User-ID</label>
<div class="col-sm-7">
<input type="text" name="user_name" class="form-control" id="input1" placeholder="your user-id" />
</div>
</div>
<div class="form-group">
<label for="input1" class="col-sm-3 control-label">Password</label>
<div class="col-sm-7">
<input type="password" name="password" class="form-control" id="input1" placeholder="your password" />
</div>
</div>
<div class="form-group" class="radio">
<label for="input1" class="col-sm-3 control-label">Role</label>
<div class="col-sm-7">
<label>
<input type="radio" name="user_type" id="optionsRadios1" value="mentee" checked> Mentee
</label>
<label>
<input type="radio" name="user_type" id="optionsRadios1" value="mentor"> Mentor
</label>
<label>
<input type="radio" name="user_type" id="optionsRadios1" value="admin"> Admin
</label>
</div>
</div>
<input type="submit" class="btn btn-primary col-md-3 col-md-offset-7" value="Login" name="login" />
</form>
</div>
</div>
<br><br>
<p><strong>Have forgot your password? <a href="reset.php">Reset here.</a></strong></p>
<!-- <p><strong>If you don't have any account, <a href="signup.php">Signup</a> here</strong></p> -->
</center>
</body>
</html>