1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
---|
5 | <meta content="utf-8" http-equiv="encoding">
|
---|
6 | <title>User Log in</title>
|
---|
7 | </head>
|
---|
8 | <body>
|
---|
9 | <center>
|
---|
10 | <fieldset style="width: 300px">
|
---|
11 | <legend> Login here </legend>
|
---|
12 | <table>
|
---|
13 | <tr>
|
---|
14 | <td>User name (required)</td>
|
---|
15 | <td><input type="text" id="name" name="username"
|
---|
16 | required="required" /></td>
|
---|
17 | </tr>
|
---|
18 | <tr>
|
---|
19 | <td>Password</td>
|
---|
20 | <td><input type="password" id="password" name="userpass"
|
---|
21 | required="required" /></td>
|
---|
22 | </tr>
|
---|
23 | <tr>
|
---|
24 | <td><button onClick="login()">Log in</button></td>
|
---|
25 | </tr>
|
---|
26 | </table>
|
---|
27 | </fieldset>
|
---|
28 | <br> <br>
|
---|
29 | <table>
|
---|
30 | <tr>
|
---|
31 | <td><a href="register.html">Register as new user<//a></td>
|
---|
32 | </tr>
|
---|
33 | <tr>
|
---|
34 | <td><a href="reset.html">I forgot my password<//a></td>
|
---|
35 | </tr>
|
---|
36 | </table>
|
---|
37 | <a href="loggedin.jsp">go on</a>
|
---|
38 |
|
---|
39 | </center>
|
---|
40 |
|
---|
41 | <script>
|
---|
42 | "use strict";
|
---|
43 |
|
---|
44 | function login() {
|
---|
45 | var xmlHttp = new XMLHttpRequest();
|
---|
46 | xmlHttp.open("POST", "AccountServlet", true);
|
---|
47 | xmlHttp.setRequestHeader('Content-Type', "text/json");
|
---|
48 | xmlHttp.onreadystatechange = function() {
|
---|
49 | if (xmlHttp.readyState == 4) {
|
---|
50 | if (xmlHttp.status == 200) {
|
---|
51 | //window.location.href = "loggedin.html";
|
---|
52 | /* var path = window.location.href;
|
---|
53 | var i = path.lastIndexOf("/") + 1;
|
---|
54 | var loc = path.substring(0, i).concat("loggedin.html");
|
---|
55 | window.location.href(loc);
|
---|
56 | */ alert("logged in!");
|
---|
57 | } else {
|
---|
58 | alert("access denied!");
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
62 | xmlHttp.send(JSON.stringify({
|
---|
63 | 'name' : document.getElementById('name').value,
|
---|
64 | 'password' : document.getElementById('password').value
|
---|
65 | }));
|
---|
66 |
|
---|
67 | }
|
---|
68 | </script>
|
---|
69 |
|
---|
70 | <noscript>Sorry, your browser does not support JavaScript!</noscript>
|
---|
71 | </body>
|
---|
72 | </html>
|
---|