-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignupmodule.php
159 lines (120 loc) · 5.37 KB
/
signupmodule.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
<?php
if( isset($_POST['registerBtn'])
&& !empty($_POST['CustomerName'])
&& !empty($_POST['Email'])
&& !empty($_POST['Phonenumber'])
&& !empty($_POST['latitude'])
&& !empty($_POST['longitude'])
&& !empty($_POST['Password'])
){
$c_lat = $_POST['latitude'];
$c_lon = $_POST['longitude'];
$command = escapeshellcmd("python essential/kdtree_nn.py $c_lat $c_lon");
$output = shell_exec($command);
$sid = 1;
if($output){
$sid = $output;
}
require_once('essential/customer.php');
$res = registerCustomer($_POST['CustomerName'], $_POST['Email'], $_POST['Phonenumber'], $_POST['Password'], $_POST['latitude'], $_POST['longitude'], $sid);
if($res){
echo "<h3>Registered Successfully.</h3>";
header('Location:index.php');
}else{
echo "<h3>Failed to register.</h3>";
}
}
?>
<div class="centre">
<h2>Signup</h2>
<div id="signupform">
<form method="post">
<table id="signuptbl" class="centre-table">
<tr>
<td><label>Customer Name : </label></td>
<td><input type="text" placeholder="Customer Name" name="CustomerName" minlenght=3 required ></td>
</tr>
<tr>
<td> <label>Email Address : </label></td>
<td><input type="email" placeholder="abc@gmail.com" name="Email" required ></td>
</tr>
<tr>
<td> <label>Phone Number : </label> </td>
<td><input type="tel" placeholder="8976435670" name="Phonenumber" pattern="[8-9]{1}[0-9]{9}" required ></td>
</tr>
<tr>
<td> <label>Address : </label> </td>
<td>
<input type="number" step="any" id="lat" placeholder="Latitude" name="latitude" required >
</br> <input type="number" step="any" id="lng" placeholder="Longitude" name="longitude" required >
</td>
</tr>
<tr>
<td> <label>Password : </label> </td>
<td><input type="Password" placeholder="Enter Password." name="Password" minlength=8 required ></td>
</tr>
<tr >
<td colspan='2'>
<input type="submit" name = "registerBtn" value="Register">
</td>
</tr>
</table>
</form>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.3.0/mapbox-gl-geocoder.min.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.3.0/mapbox-gl-geocoder.css' type='text/css' />
<div class="geocoder">
<div id="geocoder" ></div>
</div>
<div id="map"></div>
<script>
var user_location = [77.8965,29.8649];
mapboxgl.accessToken = 'pk.eyJ1IjoiZmFraHJhd3kiLCJhIjoiY2pscWs4OTNrMmd5ZTNra21iZmRvdTFkOCJ9.15TZ2NtGk_AtUvLd27-8xA';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
center: user_location,
zoom: 10
});
// geocoder here
var geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken
});
var marker ;
// After the map style has loaded on the page, add a source layer and default
// styling for a single point.
map.on('load', function() {
addMarker(user_location,'load');
// Listen for the `result` event from the MapboxGeocoder that is triggered when a user
// makes a selection and add a symbol that matches the result.
geocoder.on('result', function(ev) {
console.log(ev.result.center);
});
});
map.on('click', function (e) {
marker.remove();
addMarker(e.lngLat,'click');
document.getElementById("lat").value = e.lngLat.lat;
document.getElementById("lng").value = e.lngLat.lng;
});
function addMarker(ltlng,event) {
if(event === 'click'){
user_location = ltlng;
}
marker = new mapboxgl.Marker({draggable: true,color:"#d02922"})
.setLngLat(user_location)
.addTo(map)
.on('dragend', onDragEnd);
}
function onDragEnd() {
var lngLat = marker.getLngLat();
document.getElementById("lat").value = lngLat.lat;
document.getElementById("lng").value = lngLat.lng;
console.log('lng: ' + lngLat.lng + '<br />lat: ' + lngLat.lat);
}
document.getElementById('geocoder').appendChild(geocoder.onAdd(map));
</script>