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
require_once '../include/DBConnect.php'; if (!isset($_POST['event_id']) && !isset($_POST['activity_id'])) { SaveActivity($_POST, SaveEvent($_POST)); } else { DeleteRecord($_POST); SaveActivity($_POST, SaveEvent($_POST)); } ?> <script> alert("Insert data successful!!"); window.location.href = "Event_List.php"; </script>
<?php
function SaveEvent($POST) { global $dbh; $sth = $dbh->prepare("INSERT INTO `event`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `event_code`, `program_id`, `subject_id`, `class_size`, `programme_fee_type`, `primary_individual_price`, `primary_group_price`, `primary_package_price`, `secondary_individual_price`, `secondary_group_price`, `secondary_package_price`, `is_free`, `school_id`) VALUES(1,now(),1,now(),1,0,?,?,?,?,5,0,0,0,0,0,0,1,?) "); $sth->bindParam(1, $POST['code']); $sth->bindParam(2, $POST['programme']); $sth->bindParam(3, $POST['subject']); $sth->bindParam(4, $POST['classsize']); $sth->bindParam(5, $POST['schoolid']); $sth->execute(); return $event_id = $dbh->lastInsertId(); }
function SaveActivity($POST, $event_id) { global $dbh; $sth = $dbh->prepare("INSERT INTO `activity`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `event_id`, `title`, `date`, `start_time`, `end_time`, `payment`, `number_attend`) VALUES (1,now(),1,now(),1,0,?,?,?,?,?,?,?)"); $sth->bindParam(1, $event_id); $sth->bindParam(2, $POST['title']); $sth->bindParam(3, $POST['date']); $sth->bindParam(4, $POST['starttime']); $sth->bindParam(5, $POST['endtime']); $sth->bindParam(6, $POST['payment']); $sth->bindParam(7, $POST['numberofattend']); $sth->execute(); }
function DeleteRecord($POST) { global $dbh; $dbh->query("Update event set deleted = 1 where event_id = " . $POST['event_id']); $dbh->query("Update activity set deleted = 1 where activity_id = " . $POST['activity_id']); } ?>
|