-
Notifications
You must be signed in to change notification settings - Fork 0
/
addlocation.php
executable file
·44 lines (38 loc) · 1.73 KB
/
addlocation.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
<?
session_start();
include("db.php");
$user_id = $_SESSION['userid'];
if( $_REQUEST['add_location'] ) {
$loc_name = trim(addslashes($_REQUEST['loc_name']));
$loc_lat = trim($_REQUEST['lat']);
$loc_lng = trim($_REQUEST['lng']);
$loc_state_id = trim($_REQUEST['state']);
$sql = "select state from migwatch_states where state_id='$loc_state_id'";
$result = mysql_query($sql);
while ($data = mysql_fetch_assoc($result)){
$loc_state = $data['state'];
}
$loc_city = trim($_REQUEST['city']);
$loc_country = trim($_REQUEST['country']);
$loc_zoom = trim($_REQUEST['zoom']);
$loc_sighting = trim($_REQUEST['sighting']);
if( strtolower($loc_country) != 'india' ) {
echo "<div class='notice'>Please choose a location only from India</div>";
} else if ( ($loc_state != '') && ($loc_name != '') && ($loc_lat != '') && ($loc_lng != '') ) {
$sql = "INSERT INTO migwatch_locations (location_name,city,state_id,latitude,longitude,created_by_user_id,loc_map_zoom) VALUES ('$loc_name','$loc_city','$loc_state_id','$loc_lat','$loc_lng','$user_id','$loc_zoom')";
mysql_query($sql);
$lastInsertId = mysql_insert_id();
$sql = "INSERT INTO migwatch_user_locs (user_id,location_id) VALUES ($_SESSION[userid],$lastInsertId)";
mysql_query($sql);
?>
<script>
var loc = "<? echo $loc_name; ?>, " + "<? echo $loc_city; ?>, " + "<? echo $loc_state; ?>";
var sighting = '<? echo $loc_sighting; ?>';
var loc_id = '<? echo $lastInsertId; ?>';
parent.new_info(loc_id,loc);
parent.tb_remove();
</script>
<?
}
}
?>