-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_aoi_ajax.php
48 lines (37 loc) · 1.15 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
43
44
45
46
47
48
<?php
session_start();
require("pr_config.php");
//$dsn = "pgsql:dbname=prgap;host=127.0.0.1";
$user = "postgres";
$password ="";
try{
$dbh = new PDO($pdo_dsn, $user, $password);
} catch(Exception $e) {
echo "PDO connection error";
}
$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();
?>