-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauth.js
55 lines (52 loc) · 1.77 KB
/
auth.js
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
var xhttp = new XMLHttpRequest();
function signupSubmit(e){
var data = $("#signupForm").serialize();
//"?first_name=Chris%20Ray&last_name=Belarmino&email=cbelarmino@usc.edu.ph&password=123456&confirm_password=123456"
$.ajax({
type : 'POST',
url : 'signup_action.php',
data : data,
success : function(response) {
var res = JSON.parse(response);
alert(res["message"]);
if(res["status"] == 200){
$('#signupForm')[0].reset();
}
}
});
e.preventDefault();
}
function signinSubmit(e){
var url = "signin_action.php";
var data = $("#signinForm").serialize();
var urlData = url+"?"+data;
xhttp.open("GET", urlData, true);
xhttp.send();
xhttp.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
var res = JSON.parse(this.responseText);
if(res["status"] == 200){
$('#signinForm')[0].reset();
window.location.replace('home.php'); //replaces the current location
//window.location = '../public/home.php'; //navigates to another location
}else{
alert(res["message"]);
}
}
};
e.preventDefault();
}
function signoutClick(e){
var url = "signout_action.php";
xhttp.open("GET", url, true);
xhttp.send();
xhttp.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
var res = JSON.parse(this.responseText);
if(res["status"] == 200){
window.location.replace('index2.php'); //replaces the current location
//window.location = '../public/index.php'; //navigates to another location
}
}
};
}