-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.php
56 lines (50 loc) · 1.42 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
<!DOCTYPE html>
<html>
<head>
<title>FET Login</title>
<link rel="stylesheet" type="text/css" href="Style/formStyle.css">
</head>
<body>
<div id="wrapper">
<header>
<h1 class="mainheader">FET Login</h1><!--end mainheader-->
</header>
<form name="login" action="" method="post">
<fieldset style="width: 275px; height: 275px; margin: 0 auto;">
<legend>Login</legend>
<label>User ID:</label><input type="text" name="id" /><br />
<label>Password:</label><input type="password" name="pwd" /><br />
<input class="buttons" type="submit" value="Login" name="login" /><br />
<input class="buttons" type="submit" value="SignUp" name="signup"/>
</fieldset>
</form>
</div>
</body>
</html>
<?php
include 'PHP/db_connect.php';
if(isset($_REQUEST['login'])){
$id = $_POST['id'];
$pwd = $_POST['pwd'];
$sql = "SELECT * FROM `$users` WHERE `user_name`='$id' and `password` = '$pwd';";
$result = $mysqli->query($sql);
$count = $result->num_rows;
if ($count==1) {
session_start();
$_SESSION['user']['username'] = $id;
header("Location: timetables.php");
exit;
}
else {
echo "<script type=\"text/javascript\">
window.alert(\"Your username or password is incorrect! Please try again!\")
</script>";
}
$result->free();
$mysqli->close();
}
if(isset($_REQUEST['signup'])){
header("Location: signup.php");
exit;
}
?>