-
Notifications
You must be signed in to change notification settings - Fork 30
/
edit_event.php
182 lines (84 loc) · 3.85 KB
/
edit_event.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
include('dbconnect.php');
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES["thumbnail"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
$extension = explode("/", $_FILES["thumbnail"]["type"]);
if(isset($_POST['submit'])){
$id = $_GET['id'];
$eventtitle = $_POST['eventtitle'];
$desc = $_POST['desc'];
$category = $_POST['category'];
$eventtype = $_POST['eventtype'];
$price = $_POST['price'];
$time = $_POST['time'];
$eventdate = $_POST['eventdate'];
list($a, $b) = explode("-",$eventdate);
$rawdate = htmlentities($a);
$startdate = date('Y-m-d', strtotime($rawdate));
$rawdate1 = htmlentities($b);
$enddate = date('Y-m-d', strtotime($rawdate1));
$venue = $_POST['venue'];
$sponsors = $_POST['sponsors'];
if($eventtitle !=''||$desc !=''){
foreach ($_POST['rules'] as $value) {
$yo[]= $value;
}
foreach ($_POST['prize'] as $value) {
$yo1[]= $value;
}
$rule= implode(" , ",$yo);
$prize= implode(" , ",$yo1);
// Check file size
if ($_FILES["thumbnail"]["size"] > 500000000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
// Check if $uploadOk is set to 0 by an error
$yo = basename($_FILES["thumbnail"]["name"]);
if(!$yo)
{
$image = null;
}
else{
if (move_uploaded_file($tmp, "images/" . $eventtitle.".".$extension[1])) {
echo "The file ". basename( $_FILES["thumbnail"]["name"]). " has been uploaded.";
}
$image=$eventtitle.".".$extension[1];
}
if($eventtype== "Team Event"){
$min_team= $_POST['min_team_size'];
$max_team= $_POST['max_team_size'];
if(!$image){
$sql = "UPDATE create_event SET Event_TITLE = '$eventtitle', EVENT_DESC = '$desc', Category = '$category', eventtype = '$eventtype', min_team = '$min_team', max_team = '$max_team', EVENT_RULES = '$rule', startdate = '$startdate', enddate = '$enddate', EVENT_VENUE = '$venue', time= '$time',event_price='$price', EVENT_SPONSORS = '$sponsors', EVENT_PRIZES = '$prize' WHERE create_event.Event_ID = $id";
$result = mysqli_query($conn, $sql);
}
else{
$sql = "UPDATE create_event SET Event_TITLE = '$eventtitle', EVENT_DESC = '$desc', Category = '$category', eventtype = '$eventtype', min_team = '$min_team', max_team = '$max_team', EVENT_RULES = '$rule', startdate = '$startdate', enddate = '$enddate', EVENT_VENUE = '$venue', time= '$time',event_price='$price', event_thumbnail = '$image', EVENT_SPONSORS = '$sponsors', EVENT_PRIZES = '$prize' WHERE create_event.Event_ID = $id";
$result = mysqli_query($conn, $sql);
}
}
else if($eventtype== "Single Participant" || $eventtype== "Choose the Event Type"){
if(!$image) {
$sql = "UPDATE create_event SET Event_TITLE = '$eventtitle', EVENT_DESC = '$desc', Category = '$category', eventtype = '$eventtype', min_team = '0', max_team = '0', EVENT_RULES = '$rule', startdate = '$startdate', enddate = '$enddate', EVENT_VENUE = '$venue',time= '$time',event_price='$price', EVENT_SPONSORS = '$sponsors', EVENT_PRIZES = '$prize' WHERE create_event.Event_ID = $id";
$result = mysqli_query($conn, $sql);
}
else{
$sql = "UPDATE create_event SET Event_TITLE = '$eventtitle', EVENT_DESC = '$desc', Category = '$category', eventtype = '$eventtype', min_team = '0', max_team = '0', EVENT_RULES = '$rule', startdate = '$startdate', enddate = '$enddate', EVENT_VENUE = '$venue',time= '$time',event_price='$price', event_thumbnail = '$image', EVENT_SPONSORS = '$sponsors', EVENT_PRIZES = '$prize' WHERE create_event.Event_ID = $id";
$result = mysqli_query($conn, $sql);
}
}
if (!$result) {
$result = mysqli_error($conn);
echo "<p>Insertion Failed <br/s> Some Fields are Blank....!!</p>";
}
else{
header('location: dashboard.php');
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
}
}
}
$conn->close();
?>