forked from FuseOrg/Feedie
-
Notifications
You must be signed in to change notification settings - Fork 2
/
signup.php
122 lines (118 loc) · 5.14 KB
/
signup.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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<script src="scripts/material.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Product+Sans:500,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/material.min.css">
<link rel="stylesheet" href="styles/main.css">
<link rel="icon" type="image/png" href="images/logo.png">
<title>Student Sign up | Feedie</title>
</head>
<body class="mdl-demo mdl-color-text--grey-900 mdl-base mdl-grid mdl-grid--no-spacing mdl-layout mdl-js-layout">
<section class="horizontal-banner mdl-grid mdl-grid--no-spacing mdl-cell mdl-cell--6-col-desktop mdl-cell--8-col-tablet mdl-cell--4-col-phone">
Horizontal banner
</section>
<section class="mdl-cell mdl-cell--6-col-desktop mdl-cell--8-col-tablet mdl-cell--4-col-phone section--center mdl-grid mdl-grid--no-spacing">
<form action="" method="post">
<div class="mdl-grid mdl-grid--no-spacing">
<h4 class="mdl-cell mdl-cell--12-col questions">Student sign up</h4>
<div class="mdl-cell mdl-cell--12-col questions" style="flex-direction: column;">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" name="name" id="name">
<label class="mdl-textfield__label">Name</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" name="rollno" id="rollno">
<label class="mdl-textfield__label">Register number</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="password" name="password" id="password">
<label class="mdl-textfield__label">Password</label>
<span onclick="toggler()" class="mdl-button mdl-js-button mdl-button--icon mdl-button--accent">
<i id="sp" class="material-icons">visibility_off</i>
</span>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="password" name="repassword" id="repassword">
<label class="mdl-textfield__label">Retype password</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" name="college" id="college">
<label class="mdl-textfield__label">College ID</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" name="semester" id="semester">
<label class="mdl-textfield__label">Semester</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" name="department" id="department">
<label class="mdl-textfield__label">Department</label>
</div>
</div>
<div class="mdl-cell mdl-cell--12-col questions">
<button type="submit" class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent">
Sign up
</button>
</div>
<script>
function toggler() {
if (document.getElementById("sp").innerHTML == 'visibility_off') {
document.getElementById("sp").innerHTML = 'visibility';
document.getElementById("password").type = "text";
} else {
document.getElementById("sp").innerHTML = 'visibility_off';
document.getElementById("password").type = "password";
}
}
</script>
<div class="mdl-cell mdl-cell--12-col mdl-color-text--red-a400 questions">
<?php
if (isset($_GET["logout"])){
if ($_GET["logout"] == 1){
session_start();
include('done_check.php');
session_destroy();
}
}
session_start();
if (isset($_SESSION["st_username"])){
//Add sleep here
header('Location: dashboard/');
}
$servername = "127.0.0.1";
$username = "root";
$password = "";
$dbname = "feedie_base";
if (isset($_POST["rollno"]) AND isset($_POST["password"])){
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$rollno = $_POST["rollno"];
$sql = "SELECT st_username, password, class FROM students WHERE rollno = '".$rollno."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$row = $result->fetch_assoc();
if( $_POST["password"] == $row["password"] ){
echo "Logging you in..";
session_start();
$_SESSION["rollno"] = $_POST["rollno"];
$_SESSION["st_username"] = $row["st_username"];
$_SESSION["class"] = $row["class"];
header("Location: dashboard/"); // lines
}
else
echo "Password incorrect!";
}
else {
echo "Unknown Register number!";
}
$conn->close();
}
?>
</div>
</div>
</form>
</section>
</body>
</html>