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
|
<?php require("inc/configure.php"); ?> <?php require("inc/global.php"); ?> <? session_start(); $custid = $_POST['custid']; $carid = $_POST['carid']; $licno = $_POST['licno']; $modelno = $_POST['modelno']; $chassisno = $_POST['chassisno']; $caryear = isnull($_POST['caryear'],''); $licence_expiry_date = $_POST['licence_expiry_date']; $status = $_POST['status']; $creationdate = date("YmdGis"); $creationby = $_SESSION['userid'];
if ($carid == "") { $sql = "select * from CM_CAR where ((licno = '$licno' and licno != '') or (chassisno = '$chassisno' and chassisno != '')) and status = 1 "; $result = mysql_query($sql); if ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { die('Error: Record duplicated'); } $sql = "insert into CM_CAR (custid, licno, modelno, chassisno, caryear, licence_expiry_date, status, creationdate, creationby) values($custid, '$licno', '$modelno', '$chassisno', '$caryear', '$licence_expiry_date', 1, '$creationdate', $creationby)"; $result = mysql_query($sql);
if (!$result) { die('Invalid query: ' . mysql_error()); } else { $msg = "Record created successful!"; } } else { $sql = "select * from CM_CAR where ((licno = '$licno' and licno != '') or (chassisno = '$chassisno' and chassisno != '')) and carid <> $carid and status = 1 "; $result = mysql_query($sql); if ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { die('Error: Record duplicate'); }
//**update $sql = "update CM_CAR set custid = $custid , licno = '$licno' , modelno = '$modelno' , chassisno = '$chassisno' , caryear = '$caryear' , licence_expiry_date = '$licence_expiry_date' , updateddate = '$creationdate' , updatedby = $creationby , status = $status where carid = $carid "; $result = mysql_query($sql);
if (!$result) { die('Invalid query: ' . mysql_error()); } else { $msg = "Record updated successful!"; }
} //header("Location: contactdetail.php?carid=$carid&msg=$msg"); ?>
<script language="JavaScript"> <!-- window.close(); if (window.opener && !window.opener.closed) { window.opener.location.reload(); }
//--> </script>
|