-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathannouncement_add_record.php
25 lines (24 loc) · 1 KB
/
announcement_add_record.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
<?php include 'server/server.php' ?>
<?php
$image = $_FILES["fileToUpload"]["name"];
$title = $_POST['title'];
$category = $_POST['category'];
$description = $_POST['description'];
$target_dir = "assets/img/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$create_date = date("Y-m-d");
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
$query = "INSERT INTO tbl_announcement (image,title,status,category,description,create_date)
VALUES ('$image','$title',1,'$category','$description','$create_date')";
echo $query;
$result = $conn->query($query);
$_SESSION['message'] = 'Failed to add announcement!';
$_SESSION['success'] = 'danger';
if($result){
$_SESSION['message'] = 'Successfully added announcement!';
$_SESSION['success'] = 'success';
}
header('location: announcement.php');
?>