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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<? require("inc/configure.php"); require("inc/global.php"); require("inc/checklogin.php"); if ($logged_in == 0) { //echo 'Not logged in. <a href="login.php">Login</a>'; header('Window-target: _parent'); header('Location: login.php'); exit(); } if (checkObject(5) <> 1){ die("Unauthorized Access"); exit(); } ?> <? $paymentmethodid = $_POST['paymentmethodid']; $paymentmethod = htmlspecialchars($_POST['paymentmethod'], ENT_QUOTES); $status = $_POST['status']; $creationdate = date("YmdGis");
if ($paymentmethodid == "") { $sql = "select * from SYS_PAYMENTMETHOD where paymentmethod = '$paymentmethod'"; $result = mysql_query($sql); if ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $msg = "<?=paymentmethod?> duplicate!"; } else { //**addnew $sql = "select max(paymentmethodid) as maxpaymentmethodid from SYS_PAYMENTMETHOD"; $result = mysql_query($sql); if ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { if (strlen($row{'maxpaymentmethodid'}) == 0) { $paymentmethodid = 1001; } else { $paymentmethodid = $row{'maxpaymentmethodid'} + 1; } } else { $paymentmethodid = 1001; }
$sql = "insert into SYS_PAYMENTMETHOD (paymentmethodid, paymentmethod, status, creationdate, creationby) values($paymentmethodid, '$paymentmethod', $status, '$creationdate', '$creationby')";
$result = mysql_query($sql);
if (!$result) { die('Invalid query: ' . mysql_error()); }
$msg = "Created!"; } } else { $sql = "select * from SYS_PAYMENTMETHOD where paymentmethod = '$paymentmethod' and paymentmethodid <> $paymentmethodid"; $result = mysql_query($sql); if ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $msg = "<?=paymentmethod?> duplicate!"; } else { //**update $sql = "update SYS_PAYMENTMETHOD set paymentmethod = '$paymentmethod' , status = $status , updateddate = '$creationdate' , updatedby = '$creationby' where paymentmethodid = $paymentmethodid "; $result = mysql_query($sql);
if (!$result) { die('Invalid query: ' . mysql_error()); } $msg = "Updated!"; } } header("Location: paymentmethod.php?msg=$msg"); ?>
|