-
Notifications
You must be signed in to change notification settings - Fork 3
/
Posting-Event.php
87 lines (55 loc) · 1.77 KB
/
Posting-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
<?php
session_start();
if(!isset($_SESSION['id']))
{
header('location: login.php');
exit;
}
include('config.php');
if(isset($_POST['posting']))
{
$filename = $_FILES['image']['name'];
$tempname = $_FILES["image"]["tmp_name"];
$file_extansion = pathinfo($filename, PATHINFO_EXTENSION);
$random_number = rand(0, 10000000);
$file_rename = 'File_'.date('Ymd').$random_number;
$file_complete = $file_rename.'.'.$file_extansion;
$ID = $_SESSION['id'];
$caption = $_POST['caption'];
$hashtags= $_POST['hash-tags'];
$invite_link = $_POST['event-link'];
$event_date = $_POST['event-date'];
$event_time = $_POST['event-time'];
$folder = "./assets/images/posts/" . $file_complete;
$likes = 0;
$date = date("Y-m-d H:i:s");
$sql_query = "INSERT INTO events (User_ID, Likes, Event_Poster, Caption, Event_Time, Event_Date, Invite_Link, HashTags, Date_Upload) VALUES
($ID, $likes, '$file_complete','$caption', '$event_time','$event_date','$invite_link','$hashtags','$date')";
$stmt = $conn->prepare($sql_query);
if($stmt->execute())
{
move_uploaded_file($tempname, $folder);
header("location: Events.php?success_message=Post Successfully updated");
exit;
}
else
{
header("location: Event-Upload.php?error_message=Error Occurred, DB Error");
exit;
}
}
else
{
header("location: post-uploader.php?error_message=Error Occurred, try again2 - ERROR #009");
exit;
}
function update_Posts($user_id)
{
include 'config.php';
$insert_query = "UPDATE users SET POSTS = POSTS+1 WHERE User_ID = $user_id ;";
$stmt = $conn->prepare($insert_query);
if ($stmt->execute()) {
$_SESSION['postcount'] = $_SESSION['postcount']+1;
}
}
?>