-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathueaAction.php
34 lines (31 loc) · 1.15 KB
/
ueaAction.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
<?php
include 'dbconnection.php';
$name ="";
$image ="";
$description ="";
If(isset($_POST['name'])){$name = $_POST['name'];}
If(isset($_POST['description'])){$description = $_POST['description'];}
$target_dir = "img/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
$uploadOk = 0;
}
if ($uploadOk==0) {
header("Location: UpcomingEventsAdding.php?msg=Sorry, only JPG, JPEG, PNG & GIF files are allowed.");
die();
} else {
move_uploaded_file($_FILES["image"]['tmp_name'], $target_file);
}
$Query = "Insert into events(name, image, description)values('".$name."', '".$target_file."', '".$description."')";
$result = $conn->query($Query);
if ($result===TRUE) {
header("Location: UpcomingEventsAdding.php?msg=Save Success !");
die();
}else{
header("Location: UpcomingEventsAdding.php?msg=Save Error".mysqli_error($conn));
die();
}
?>