-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_status.php
More file actions
53 lines (40 loc) · 1.57 KB
/
post_status.php
File metadata and controls
53 lines (40 loc) · 1.57 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
<?php
//enable this when finished
//error_reporting(0);
session_start();
if (file_exists('config.php')) {
include('config.php');
}
else {
include('../../config.php');
}
$conn = mysql_connect($sqlHost, $sqlUser, $sqlPass) or die("Can't connect to host : " . mysql_error());
$db = mysql_select_db($sqlDatabase, $conn) or die("Can't database to database: " . mysql_error());
$error = "";
$posting= $_POST['post_desc'];
$userid = $_SESSION['login_user'];
$lat = (string)$_POST['lat'];
$lon = (string)$_POST['lon'];
$location = $lat ." ". $lon;
$timestamp = $_POST['timestamp'];
$posting = stripslashes($posting);
$posting = mysql_real_escape_string($posting);
$userid = stripslashes($userid);
$userid = mysql_real_escape_string($userid);
$location = stripslashes($location);
$location = mysql_real_escape_string($location);
$timestamp = stripslashes($timestamp);
$timestamp = mysql_real_escape_string($timestamp);
$sql = "INSERT INTO Posts (User_ID, Post_ID, Post_Desc, Location, Time_Stamp) Values (".($userid).", NULL, '$posting', '$location', '$timestamp')";
$execute = mysql_query($sql, $conn) or die($sql . " : " . mysql_error());
$sql = "SELECT * FROM Posts as P INNER JOIN Account as A ON P.User_ID = A.User_ID WHERE P.User_ID = ".($userid)." ORDER BY Time_Stamp DESC LIMIT 1";
$table = mysql_query($sql, $conn) or die($sql . " : " . mysql_error());
$return_array = Array();
while($rec = mysql_fetch_assoc($table)) {
$temp = $rec['Firstname'];
$rec['Firstname'] = $temp."(You)";
array_push($return_array, $rec);
}
mysql_close($conn);
echo json_encode($return_array);
?>