-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete-poliza.php
54 lines (46 loc) · 1.59 KB
/
delete-poliza.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
53
54
<?php
$MM_authorizedUsers = "master";
?>
<?php require_once('inc/security-html.php'); ?>
<?php
// Require connection
require_once('Connections/connection.php');
// Require DB functions
require_once('inc/db_functions.php');
?>
<?php
if ((isset($_POST["id"])) && ($_POST["id"] != "")) {
// Recordset: Poliza
$query_Recordset1 = sprintf("SELECT subtipo_poliza_tabla FROM subtipo_poliza JOIN (poliza) ON (subtipo_poliza.subtipo_poliza_id=poliza.subtipo_poliza_id) WHERE poliza.poliza_id=%s", intval(mysql_real_escape_string($_POST["id"])));
$Recordset1 = mysql_query($query_Recordset1, $connection) or die(mysql_die());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if ($totalRows_Recordset1 !== 1) {
die("Error: Poliza no encontrada.");
}
mysql_free_result($Recordset1);
;
$deleteSQL = sprintf("DELETE FROM %s WHERE poliza_id=%s",
$row_Recordset1['subtipo_poliza_tabla'],
GetSQLValueString($_POST["id"], "int"));
mysql_query($deleteSQL, $connection);
$deleteSQL = sprintf("DELETE FROM cuota WHERE poliza_id=%s",
GetSQLValueString($_POST["id"], "int"));
mysql_query($deleteSQL, $connection);
// Delete record
$deleteSQL = sprintf("DELETE FROM poliza WHERE poliza_id=%s LIMIT 1",
GetSQLValueString($_POST["id"], "int"));
$Result1 = mysql_query($deleteSQL, $connection);
// Evaluate results
switch (mysql_errno()) {
case 0:
echo "El registro ha sido eliminado con éxito.";
break;
default:
mysql_die();
break;
}
} else {
die("Error: Acceso denegado.");
}
?>