-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_airport_func.php
More file actions
40 lines (37 loc) · 1009 Bytes
/
add_airport_func.php
File metadata and controls
40 lines (37 loc) · 1009 Bytes
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
<? require_once('check_exist.php'); ?>
<?
session_save_path("./session/");
session_start();
if(isset($_SESSION['isAuth']) && $_SESSION['isAdmin'])
{
$abbr = $_POST['abbr'];
$name = $_POST['name'];
$country = $_POST['country'];
$longitude = $_POST['longitude'];
$latitude = $_POST['latitude'];
$timezone = $_POST['timezone'];
if($id === "" || $name === "" || $longitude === "" || $latitude === "")
{
echo "insert error";
}
else
{
require_once('db.php');
$sql = "SELECT name FROM Airport WHERE abbr = ? ";
$sth = $db->prepare($sql);
$sth->execute(array($abbr));
if($airport = $sth->fetchObject())
{
echo "repeated abbr";
}
else
{
$sql = "INSERT INTO Airport (abbr, name, country, longitude, latitude, timezone)"
."VALUES (?, ?, ?, ?, ?, ?)";
$sth = $db->prepare($sql);
$sth->execute(array($abbr, $name, $country, $longitude, $latitude, $timezone));
header('Location: airport_management.php');
}
}
}
?>