generated from akshatvg/template-materialize
-
Notifications
You must be signed in to change notification settings - Fork 4
/
loginStud.php
83 lines (74 loc) · 3 KB
/
loginStud.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
<!DOCTYPE html>
<html lang="en">
<?php
include("templates/metas.php");
?>
<!-- URLs -->
<meta name="url" content="https://exc-vtop.akshatvg.com/loginStud">
<meta property="og:url" content="https://exc-vtop.akshatvg.com/loginStud">
<link rel="canonical" href="https://exc-vtop.akshatvg.com/loginStud">
<?php
include("templates/header.php");
?>
<?php
include("templates/nav-vit.php");
?>
<?php
require('db.php');
session_start();
if (isset($_POST['regNo'])) {
// Removes backslashes
$regNo = stripslashes($_REQUEST['regNo']);
// Escapes special characters in a string
$regNo = mysqli_real_escape_string($con, $regNo);
$studPass = stripslashes($_REQUEST['studPass']);
$studPass = mysqli_real_escape_string($con, $studPass);
// Checking if user exists in the database or not
$query = "SELECT * FROM `students` WHERE regNo='$regNo' and studPass='" . $studPass . "'";
$result = mysqli_query($con, $query);
$rows = mysqli_num_rows($result);
if ($rows == 1) {
$_SESSION['regNo'] = $regNo;
// Redirect user to index page
echo "<script>window.location.href='index';</script>";
} else {
echo "<script>M.toast({ html: 'Either this user doesn't exist in our database or the studPass you entered is wrong. });</script>";
}
} else {
?>
<!-- Main Content -->
<div class="container">
<!-- Login Form -->
<div class="row mt-5 mb-5">
<div class="w-100 w-md-50 mx-auto">
<div class="card white card-top-lightblue">
<div class="card-content">
<span class="card-title black-text">EXC-VTOP Login</span>
<form method="POST" action="" name="loginStud">
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">account_circle</i>
<input id="regNo" name="regNo" type="text" class="validate" pattern="[1-2][5-9][A-Za-z]{3}[0-9]{4}" required>
<label for="regNo">Registration Number</label>
</div>
<div class="input-field col s12">
<i class="material-icons prefix">lock</i>
<input id="studPass" name="studPass" type="password" class="validate" required>
<label for="studPass">Password</label>
</div>
<div class="center">
<button name="loginStudBtn" class="btn btn-exc z-depth-0 waves-effect mb-n4" id="loginStudBtn" value="Login">Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
include("templates/footer.php");
?>
</body>
</html>