-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_agn_request.php
53 lines (39 loc) · 1.4 KB
/
delete_agn_request.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
49
50
51
52
<?php
/*
*
* http://editablegrid.net
*
* Copyright (c) 2011 Webismymind SPRL
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://editablegrid.net/license
*/
require_once('config.php');
// Database connection
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']);
// Get all parameter provided by the javascript
$id = $mysqli->real_escape_string(strip_tags($_POST['id']));
$tablename = $mysqli->real_escape_string(strip_tags($_POST['tablename']));
// $receive=$mysqli->query("SELECT request_detail,agency FROM request where req_id = ".$id."");
// $row = $receive->fetch_row();
// $res=$row[0];
// $agn=$row[1];
// This very generic. So this script can be used to update several tables.
// $return=false;
if ( $stmt = $mysqli->prepare("DELETE FROM ".$tablename." WHERE req_id = ?")) {
$stmt->bind_param("i", $id);
$return = $stmt->execute();
$stmt->close();
}
$msg='Your request ( '.$res.' )has been denied.';
$table='message';
$return=false;
if ( $stmt1 = $mysqli->prepare("INSERT INTO ".$table." (msg_detail,agency) VALUES ( ?, ? )")) {
$stmt1->bind_param("si", $msg, $agn);
$return = $stmt1->execute();
$stmt1->close();
}
$mysqli->close();
echo $stmt;
echo $return ? "ok" : "error";