Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·65 lines (63 loc) · 1.95 KB
/
Copy pathindex.js
File metadata and controls
executable file
·65 lines (63 loc) · 1.95 KB
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
function openAjax()
{
var xhr;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
return xhr;
}
function createAccount()
{
var xhr = openAjax();
var email = document.getElementById('emailSignUp').value;
var username = document.getElementById('usernameSignUp').value;
var password = document.getElementById('passwordSignUp').value;
var loginarray = [email, username, password];
var logininfo = "logininfo=" + JSON.stringify(loginarray);
xhr.open("POST", "CreateAccount.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(logininfo);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var responseT = xhr.responseText;
alert(responseT);
}
else {
alert("There was a problem with the request.");
}
}
};
}
function login()
{
var xhr = openAjax();
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
var loginarray = [username, password];
var logininfo = "logininfo=" + JSON.stringify(loginarray);
xhr.open("POST", "Login.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(logininfo);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var responseT = xhr.responseText;
if (responseT == "go") {
window.location.replace("evaluation.php");
}
else {
alert(responseT);
}
}
else {
alert("There was a problem with the request.");
}
}
};
}