-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
147 lines (128 loc) · 4.98 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Rising Institute</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
#bg{
background: url("back_index.jpg") no-repeat center center fixed;
background-size: 100% 100%;
height: 100%;
position: absolute;
width: 100%;
color:white;
}
</style>
</head>
<body id="bg">
<div class="container" style="padding-top: 1%">
<div class="jumbotron">
<img class="img-responsive" src="logo.png" alt="logo" width="120" height="100" style="margin-left:0;padding-left:0;position: relative;float: left;padding-top: 0%;margin-top: 0px">
<h1 style="font-family: Acens;color: black ">THE RISING INSTITUTE</h1>
</div>
<div style="background-color: rgba(1,1,1,0.0)">
<div class="row">
<div class="col-sm-6">
<img class="img-responsive img-rounded" src="photo.png" alt="logo" width="460" height="345" style="object-fit: fill;object-position: fixed;margin-left:0;padding-left:0">
</div>
<div id="form">
<div class="col-sm-6 text-center">
<form class="form-horizontal" style="height:200%;" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<div class="radio-inline">
<label><input type="radio" name="check" id="stu_radio" value="student">Student</label>
</div>
<div class="radio-inline">
<label><input type="radio" name="check" id="fac_radio" value="faculty">Faculty</label>
</div>
<div class="form-group" style="padding-top:10px">
<label class="control-label col-sm-2" for="email">User ID:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="user_id" placeholder="Enter user id" name="uname">
</div>
</div>
<div class="form-group"><br>
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control col-sm-10" id="pwd" placeholder="Enter password" name="pword">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<br>
<button type="submit" class="btn btn-default" id="login">Login</button>
</div>
</div>
</form>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<br>
<label>OR</label>
<br>
<a href="signup.php">
<button type="button" class="btn btn-default" id="signup" >Sign Up</button>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$servername="-";
$username="-";
$password="-";
$dbname="-";
$conn=new mysqli($servername,$username,$password,$dbname);
if($conn->connect_error){
die("Connection failed: " . $conn->connect_error);
}
$check=$_POST["check"];
$user=$_POST['uname'];
$pass=$_POST['pword'];
$flag=0;
if (!empty($_POST["uname"]) && !empty($_POST["pword"]) && strcmp($check,'student')==0 && !empty($_POST["check"])) {
$sql="select * from students where id='".$user."'";
$result = $conn->query($sql);
$flag=0;
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
if (strcmp($row["id"],$user)==0 && strcmp($row["password"],$pass)==0) {
session_start();
$_SESSION['rno']=$user;
$_SESSION['class']=$row['class'];
//header("location: student_all.php");
echo "<script>window.location = 'student_all.php'</script>";
$flag=1;
}
}
if($result->num_rows==0 || $flag==0) {
echo "<script>alert('invalid username or password')</script>";
}
}
else if (!empty($_POST["uname"]) && !empty($_POST["pword"]) && strcmp($check,'faculty')==0 && !empty($_POST["check"])) {
$sql="select uid,password from faculty where uid='".$user."' and password='".$pass."'";
$result = $conn->query($sql);
$flag=0;
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
if (strcmp($row["uid"],$user)==0 && strcmp($row["password"],$pass)==0) {
session_start();
$_SESSION['user_name']=$user;
echo "<script>window.location = 'teacher_dos.php'</script>";
$flag=1;
}
}
if($result->num_rows==0 || $flag==0) {
echo "<script>alert('invalid username or password')</script>";
}
}
}
?>
</html>