-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathview2.php
35 lines (30 loc) · 975 Bytes
/
view2.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
<?php
session_start();
// If the session vars aren't set, try to set them with a cookie
if (!isset($_SESSION['username'])) {
if (isset($_COOKIE['username'])) {
$_SESSION['username'] = $_COOKIE['username'];
}
}
if((!isset($_SESSION['username'])) && (!isset($_COOKIE['username'])))
{
$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php';
header('Location: ' . $home_url);
}
$lat= $_GET['lat'];
$lng= $_GET['lng'];
$user= $_SESSION['username'];
$username=$_SESSION['username'];
$host = "localhost";
$user = "root";
$pass = "";
$database = "travel";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = mysql_query("SELECT * FROM notes WHERE (lat='$lat' AND lng='$lng')");
$rows = array();
while($row = mysql_fetch_assoc($query)) {
$rows[] = $row;
}
print json_encode($rows);
?>