-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreateAccount.php
More file actions
123 lines (99 loc) · 4.18 KB
/
createAccount.php
File metadata and controls
123 lines (99 loc) · 4.18 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
include 'database.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>Create Account | Scoot</title>
<link rel="stylesheet" type="text/css" href="styles/style.css">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="icon" type="image/png" sizes="96x96" href="icon/favicon-96x96.png">
</head>
<body>
<header>
<div class="top">
<img src="images/scoot.png" id="logo">
</div>
</header>
<div class="center">
<h3>Create New Account</h3>
<form method="POST" class="login">
<input type="text" name="username" id="username" placeholder="Username"></input>
<span id="#error-message"></span>
<input type="password" name="password" id="password" placeholder="Password"></input>
<input type="password" name="rePassword" id="rePassword" placeholder="Confirm Password"/>
<span id="passConfirm"></span>
<button type="button" name="create" value="Sign Up" id="signUpButton">Submit</button>
</form>
<br>
<a href="index.php">Login</a>
</div>
</body>
</html>
<script>
$("#username")
.change(function(e) {
var userData = {
"username": $("#username").val()
};
//console.log(userData);
$.ajax({
url: "verify.php",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(userData)
})
.done(function(data) {
console.log("Was user found?", data.found);
if (!data.found) {
$("#error-message").html("Username not found");
document.getElementById("#error-message").innerHTML = "Username Available!";
} else {
$("#error-message").html("Username found");
document.getElementById("#error-message").innerHTML = "Username Taken!";
}
})
.fail(function(xhr, status, errorThrown) {
console.log(errorThrown)
console.log("error", xhr.responseText);
});
});
$("#signUpButton").click(onButtonClicked);
function onButtonClicked(){
if($("#password").val()!=$("#rePassword").val()){
document.getElementById("passConfirm").innerHTML = "Passwords Do Not Match!";
//document.getElementById("passConfirm").className = "error";
//match = false;
return false;
}
if( document.getElementById("#error-message").innerHTML == "Username Taken!"){
return false;
}
if($("#password").val() ==""){
return false;
}
//document.getElementById("passConfirm").innerHTML = "Passwords Okay!";
//console.log("same");
var jsonData ={
"username": $("#username").val(),
"password": $("#password").val(),
"rePassword": $("#rePassword").val()
};
$.ajax({
url:"createAccountFunctions.php",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(jsonData),
})
.done(function(data){
//console.log(data);
console.log("Im done!");
window.location.replace("index.php");
})
.always(function(xhr,status){
});
}
</script>