-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_aoi_ajax.php
42 lines (32 loc) · 1.06 KB
/
save_aoi_ajax.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
<?php
session_start();
$dsn = "pgsql:dbname=swgap;host=127.0.0.1";
$user = "postgres";
$password ="";
$dbh = new PDO($dsn, $user, $password);
$user = $_SESSION['username'];
$desc = trim($_POST['desc']);
$aoiname = $_POST['aoiname'];
$del = $_POST['del'];
//echo json_encode(array("desc"=>$desc, "aoiname"=>$aoiname, "del"=>$del));die();
if ($del == 'delete'){
$query = "update aoi set username = NULL where name = :aoiname";
$stmt = $dbh->prepare($query);
$stmt->bindParam(':aoiname', $aoiname);
$stmt->execute();
}elseif (!empty($desc)){
$query1 = "update aoi set username = :user where name = :aoiname";
$stmt = $dbh->prepare($query1);
$stmt->bindParam(':aoiname', $aoiname);
$stmt->bindParam(':user', $user);
$stmt->execute();
$query2 = "update aoi set description = cast( :desc as character(100)) where name = :aoiname";
$stmt = $dbh->prepare($query2);
$stmt->bindParam(':desc', $desc);
$stmt->bindParam(':aoiname', $aoiname);
$stmt->execute();
} else {
echo json_encode(array("success"=>false));die();
}
echo json_encode(array("success"=>true));die();
?>