-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
44 lines (31 loc) · 1.15 KB
/
post.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
<?php
include("config.php");
if(empty($_SESSION['id'])){
header('location:login.html');
exit;
}
// Insertion
if((isset($_FILES["fileToUpload"]) && !empty($_FILES["fileToUpload"]['name'])) || !empty($_POST["description"])){
//pour les images
$id_User = $_SESSION['id'];
//pour objectposts
$description = isset($_POST["description"])?$_POST["description"]:null;
//pour events
$Date = isset($_POST["Date"])?$_POST["Date"]:null;
$Location = isset($_POST["Location"])?$_POST["Location"]:null;
$Status = isset($_POST["Status"])?$_POST["Url_Media"]:"Public";
$req = mysqli_prepare($db, "INSERT INTO objectposts (ID_User, Description) VALUES (?, ?)");
mysqli_stmt_bind_param($req, "is", $id_User, $description);
mysqli_stmt_execute($req);
$lastid = mysqli_insert_id($db);
$target_file = null;
//upload de l'image w3schools.com
include("uploadPicture.php");
$req = mysqli_prepare($db, "INSERT INTO events (ID_Object, Date, Location, Status) VALUES(?, ?, ?, ?)");
mysqli_stmt_bind_param($req, "isss", $lastid, $Date, $Location, $Status);
mysqli_stmt_execute($req);
mysqli_stmt_close($req);
}
header('location:index.php');
exit;
?>