-
Notifications
You must be signed in to change notification settings - Fork 1
/
visitorregistration.js
49 lines (42 loc) · 1.1 KB
/
visitorregistration.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
function query(sql, callback) {
$.ajax({
url:"http://localhost:3000/query",
data: {statement: sql},
dataType: "jsonp",
//headers: {'Access-Control-Allow-Origin': *},
//crossDomain: true,
}).done(function(result){
callback(result);
});
}
function insert(sql) {
$.ajax({
url:"http://localhost:3000/query",
data: {statement: sql},
dataType: "jsonp"
});
}
$(function() {
//document has loaded
//alert(document.cookie);
$('#submit').click(function() {
var email = $('#email').val();
var name = $('#name').val();
var password = $('#password').val();
var checkpass = $('#passwordcheck').val();
if(email.length && name && password && checkpass) {
if(password == checkpass) {
//query database and get all
var sql = "Insert Into USER (Username, Email, Password, Usertype) " +
"Values (\'" + name + "\',\'" + email + "\', \'" + password + "\', \'Visitor\')";
insert(sql);
document.cookie = name;
document.location = "/visitor/visitorhome.html";
} else {
alert("password and check password must match");
}
} else {
alert("error");
}
});
});