-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathindex.php
133 lines (119 loc) · 5.08 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
<?php session_start(); ?>
<html>
<head>
<title>Online Examination System</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
</head><?php
if (isset($_POST['login'])) {
if (isset($_POST['usertype']) && isset($_POST['username']) && isset($_POST['pass'])) { require_once 'sql.php';
$conn = mysqli_connect($host, $user, $ps, $project);if (!$conn) {
echo "<script>alert(\"Database error retry after some time !\")</script>";
}
$type = mysqli_real_escape_string($conn, $_POST['usertype']);
$username = mysqli_real_escape_string($conn, $_POST['username']);
$password = mysqli_real_escape_string($conn, $_POST['pass']);
$password = crypt($password, 'rakeshmariyaplarrakesh');
$sql = "select * from " . $type . " where mail='{$username}'";
$res = mysqli_query($conn, $sql);
if ($res == true) {
global $dbmail, $dbpw;
while ($row = mysqli_fetch_array($res)) {
$dbpw = $row['pw'];
$dbmail = $row['mail'];
$_SESSION["name"] = $row['name'];
$_SESSION["type"] = $type;
$_SESSION["username"] = $dbmail;
}
if ($dbpw === $password) {
if ($type === 'student') {
header("location:homestud.php");
} elseif ($type === 'staff') {
header("Location: homestaff.php");
}
} elseif ($dbpw !== $password && $dbmail === $username) {
echo "<script>alert('password is wrong');</script>";
} elseif ($dbpw !== $password && $dbmail !== $username) {
echo "<script>alert('username name not found sing up');</script>";
}
}
}
}
?>
<style>
@media screen and (max-width: 620px) {
input {
height: 6vw !important;
}
.seluser {
display: grid;
}
.sub {
width: 20vw !important;
}
}
.inp {
box-sizing: content-box !important;
width: 30vw;
height: 3vw;
border-radius: 10px;
border: 2px solid black;
padding-left: 2vw;
font-weight: bolder;
outline: none;
}
::placeholder {
font-weight: bold;
font-family: 'Courier New', Courier, monospace;
}
label {
font-weight: bolder;
font-size: 1.5vw;
}
form {
font-size: 1.5vw;
margin: 0;
}
button:hover {
background-color: #fff !important;
}
.bg {
background-size: 100%;
}
a {
color: #042A38;
}
.login{
max-height: 70vh;
}
</style>
<body style="margin:0;height: 100%;ouline:none;color: #042A38f !important;padding-botton:5vw;">
<div class="bg" style="font-weight: bolder;background-image: url(./images/rakesh.png);background-repeat: no-repeat;padding: 0;margin: 0;background-size: cover;font-family: 'Courier New', Courier, monospace;opacity: 0.9;height: 100%;">
<center>
<h1 class="w3-container" style=" color:#042A38;text-transform: uppercase;width: auto;background:#fff;padding: 1vw;">ONLINE
Examination System</h1>
</center>
<center>
<div class="w3-card" class="login" style="color: #042A38;width: 40vw;background-color: #ffffffab;border: 2px solid black;padding: 2vw;font-weight: bolder;margin-top: 10vh;border-radius: 10px;">
<form method="POST">
<div class="seluser">
<input type="radio" name="usertype" value="student" required>STUDENT
<input type="radio" name="usertype" value="staff" required>STAFF
</div><br><br>
<div class="signin">
<label for="username" style="text-transform: uppercase;">Username</label><br><br>
<input type="email" name="username" placeholder=" Email" class="inp" required>
<br><br>
<label for="password" style="text-transform: uppercase;">Password</label><br><br>
<input type="password" name="pass" placeholder="******" class="inp" required>
<br><br>
<input name="login" class="sub" type="submit" value="Login" style="height: 3vw;width: 10vw;font-family: 'Courier New', Courier, monospace;font-weight: bolder;border-radius: 10px;border: 2px solid black;background-color:lightblue"><br>
</form><br>
<a href="reset.php">Forgot password?</a> New user! <a href="signup.php">SIGN UP</a>
</div>
</div>
</center>
</div>
<?php require("footer.php"); ?>
</body>
</html>