-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
93 lines (71 loc) · 2.73 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
<?php
session_start();
include 'loginFunctions.php';
if(isset($_POST['guestBtn'])){
$_SESSION['loggedIn'] = "No";
header('Location: home.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login | Scoot</title>
<link rel="stylesheet" type="text/css" href="styles/style.css">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="icon" type="image/png" sizes="96x96" href="icon/favicon-96x96.png">
</head>
<body>
<header>
<div class="top">
<img src="images/scoot.png" id="logo">
</div>
</header>
<div class="center">
<h3>Let's Scoot!</h3>
<form method="POST" class="login">
<input type="text" name="username" id ="username" placeholder="Username"></input>
<input type="password" name="password" id="password" placeholder="Password"></input>
<button type="button" id="submitBtn" value="Login">Submit</button>
</form>
<br>
<div class = "error">
</div>
<a href="createAccount.php">Create New Account</a>
<br>
<form method="POST" class = "login">
<input type="submit" name="guestBtn" value="Continue as Guest">
</form>
</div>
</body>
</html>
<script>
$("#submitBtn").click(onButtonClicked);
function onButtonClicked() {
var jsonData = {
"username": $("#username").val(),
"password" : $("#password").val()
};
$.ajax({
// The URL for the request
url: "loginFunctions.php",
// Whether this is a POST or GET request
type: "POST",
// The type of data we expect back
dataType: "json",
contentType: "application/json",
data: JSON.stringify(jsonData),
})
.done(function(data) {
if(data["data"] == false){
$(".error").empty();
$(".error").html("Invalid Credentials<br>");
}
else{
window.location.replace("functions.html");
}
})
.always(function(xhr, status) {
});
}
</script>