-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_post.php
executable file
·39 lines (35 loc) · 1.23 KB
/
create_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
<?php
include 'database.php';
$con = init_db();
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
session_start();
if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true)
{
$sql = "INSERT INTO Project(category, title, video, thumbnail, content, author)
VALUES ('" . mysqli_real_escape_string($con, $_POST['category']) . "',
'" . mysqli_real_escape_string($con, $_POST['title']) . "',
'" . mysqli_real_escape_string($con, $_POST['youtube_video_id']) . "',
'" . mysqli_real_escape_string($con, $_POST['logo_url']) . "',
'" . mysqli_real_escape_string($con, $_POST['description']) . "',
'" . $_SESSION['user_id'] . "');";
$result = mysqli_query($con, $sql);
if(!$result)
{
echo 'Something went wrong while registering. Please try again later.';
echo mysqli_error($con);
}
else
{
// Redirect to the project page
$referer = $_SERVER['HTTP_REFERER'];
header("Location: $referer");
}
}
else
{
echo 'You need to sign in first';
}
}
mysqli_close($con);
?>