blob: f090108d0cfdcb0db16665b410955a3f3e525a20 (
plain)
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
|
<!doctype html>
<html lang="en">
<head>
<title>Mark's Database - Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="/css/styles.css">
<script>
let usernameEl = document.getElementById('username');
let passwordEl = document.getElementById('password');
function sendPost(){
let username = usernameEl.value;
let password = passwordEl.value;
fetch(new Request("/login", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({'username':username, 'password':password})
}))
.then((response) => {
console.log(response);
window.location = "/";
});
}
let onEnterEvent = function(event) {
if (event.keyCode === 13) {
sendPost()
}
}
usernameEl.addEventListener("keyup", onEnterEvent);
passwordEl.addEventListener("keyup", onEnterEvent);
</script>
</head>
<body>
<div>
<h1>Login</h1>
<form method="post" action="/login">
<input name="username" type="text" placeholder="Enter Username" required>
<input type="password" placeholder="Enter Password" name="password" required>
<input type="submit" vallue="Log in">
</div>
</div>
</body>
</html>
|