-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
174 lines (155 loc) · 7.85 KB
/
signup.php
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php include './conn/conn.php' ?>
<?php include './includes/Session.php' ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signup | Party Jungle Toys & Party Needs</title>
<?php include './includes/header.php' ?>
</head>
<body>
<?php include './includes/top_header.php' ?>
<main class="main">
<section class="signup">
<div class="container">
<div class="row my-5 align-items-center">
<div class="col-md-4">
<div class="row justify-content-center">
<div class="col-md-9">
<img src="./assets/images/ban_img1.png" alt="" class="img-fluid">
<p class="text-secondary text-center">Party Jungle Toys and Party Needs</p>
</div>
</div>
</div>
<div class="col-md-6">
<form action="signup_submit.php" id="signup-form" method="post">
<input type="hidden" name="state" id="state-box">
<input type="hidden" name="town" id="town-box">
<p class="mt-1 mb-4 fs-4 ">Sign Up</p>
<div class="mb-3 row mt-3 mb-3">
<div class="col-md">
<label for="" class="form-label">Firstname:</label>
<input type="text" class="form-control" name="firstname">
</div>
<div class="col-md">
<label for="" class="form-label">Middlename:</label>
<input type="text" class="form-control" name="middlename">
</div>
</div>
<div class="row mb-3">
<div class="col-md">
<label for="" class="form-label">Lastname:</label>
<input type="text" class="form-control" name="lastname">
</div>
<div class="col-md">
<label for="" class="form-label">Home Address:</label>
<input type="text" class="form-control" disabled id="home-address" name="address">
<div class="text-end">
<a href="#" role="button" id="detect-btn" class="my-0 text-end text-uppercase link-orange text-decoration-underlin"><small><i class='bx bx-current-location'></i> Find my location</small></a>
</div>
<!-- <p class="form-text">Click on find my location below to automatically detect your current location.</p> -->
</div>
</div>
<div class="row mb-3 ">
<div class="col-md">
<label for="" class="form-label">Contact:</label>
<input type="text" pattern="[0-9]{11}" class="form-control" name="contact">
<p class="form-text fw-light mb-0 mt-1">
Eleven (11) digits phone number.
</p>
</div>
<div class="col-md">
<label for="" class="form-label">Email Address:</label>
<input type="email" class="form-control" id="email" name="email">
<p class="form-text text-danger my-1" id="email-exist-label">
</p>
</div>
</div>
<div class="row mb-4 ">
<div class="col-md">
<label for="" class="form-label">Username:</label>
<input type="text" class="form-control" id="username" name="username">
<p class="form-text text-danger my-1" id="username-exist-label">
</p>
</div>
<div class="col-md">
<label for="" class="form-label">Password:</label>
<input autocomplete="true" type="password" class="form-control" pattern=".{8,}" name="password">
<p class="form-text fw-light mb-0 mt-1">
Password must be 8 characters or more.
</p>
</div>
</div>
<div class="d-grid">
<button class="btn btn-orange" id="submit-btn" type="submit" name="submit">Create Account</button>
</div>
</form>
</div>
</div>
</div>
</section>
</main>
<?php include './includes/scripts.php' ?>
<script>
var validated = false;
$("#signup-form").on("submit", function(e) {
if (validated === true) {
return;
}
e.preventDefault();
e.stopPropagation()
e.stopImmediatePropagation()
showLoading();
const email = $("#email").val();
const username = $("#username").val();
$.ajax({
url: "check_user_exist.php",
method: "POST",
data: {
email,
username
},
dataType: "json",
success: function(res) {
console.log('res: ', typeof(res.allowed))
if (res.allowed === false) {
hideLoading();
if (res.email_exists) {
$("#email-exist-label").html("Email address is already taken.")
}
if (res.username_exists) {
$("#username-exist-label").html("Username is already taken.")
}
validated = false;
} else {
validated = true;
$("#submit-btn").trigger('click')
}
}
})
})
$("#detect-btn").on("click", function(e) {
e.preventDefault();
getLocation();
})
const getLocation = () => {
$("#home-address").val("...").attr("disabled", true)
navigator.geolocation.getCurrentPosition(function(position) {
console.log("Latitude is :", position.coords.latitude);
console.log("Longitude is :", position.coords.longitude);
let latitude = position.coords.latitude;
let longitude = position.coords.longitude
let url = `https://geocode.maps.co/reverse?lat=${latitude}&lon=${longitude}`
axios.get(url).then(res => {
console.log(res)
$("#state-box").val(res.data.address.state)
$("#town-box").val(res.data.address.town)
$("#home-address").val(res.data.display_name).removeAttr("disabled")
})
});
}
</script>
</body>
</html>