-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateLocation.php
More file actions
47 lines (38 loc) · 1.25 KB
/
updateLocation.php
File metadata and controls
47 lines (38 loc) · 1.25 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
<?php
function getLocation(){
//This lets us call the access token authentication function
include login.php;
//Get the access token
$at = $_POST["at"];
//check the access token and store it in $check (array)
$check = checkAT($at);
if ($check[0] == '1a'){
//If the first element of the check array is the success(exisiting user) character
//get the POST data to be updated
$data = $_POST["data"];
updateDB($check[1], $data);
echo '1';
}
else {
//in this case the authentication didn't work so return failure
echo '2';
}
}
function updateDB($user, $data){
$servername = "localhost";
$username = "sudocode";
$password = "sud0mcnuggets!";
$user_id = $user->getProperty('id');
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$mysql_init = 'USE sudocode_blossom';
$conn->query($mysql_init);
$user_update = "UPDATE user_data SET location_e = '".$data[0]."', location_n = '".$data[1]."' WHERE fb_id = '".$user_id."'";
$conn->query($user_update);
$conn->close();
}
?>