-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmyphpfile.php
More file actions
37 lines (33 loc) · 1.09 KB
/
myphpfile.php
File metadata and controls
37 lines (33 loc) · 1.09 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
<?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'];
echo $lat;
$lng= $_GET['lng'];
echo $lng;
$shelter = $_GET['shelter'];
echo $shelter;
$atmnote = $_GET['atmnote'];
echo $atmnote;
$user= $_SESSION['username'];
$dbc = mysqli_connect('localhost', 'root', '', 'travel')
or die('Error connecting to MySQL server.');
$query = "INSERT INTO notes (username,lat,lng,shelter,atmnote)".
"VALUES ('$user','$lat','$lng','$shelter','$atmnote')";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
echo $result;
mysqli_close($dbc);
$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/view.php';
header('Location: ' . $home_url);
?>