2021-06-02 07:01:51 +00:00
|
|
|
<?php
|
|
|
|
//require our bootstrap file for database connection
|
|
|
|
require "../../bootstrap.php";
|
|
|
|
|
|
|
|
use Backend\Model\Post;
|
|
|
|
|
|
|
|
//Chek if the user did press the button on the home pages
|
|
|
|
if(isset($_POST['createPost'])){
|
|
|
|
//Grep the data from post
|
|
|
|
$title = $_POST['title'];
|
|
|
|
$description = $_POST['description'];
|
|
|
|
|
|
|
|
//Create a new initialize
|
|
|
|
$post = new Post();
|
|
|
|
|
|
|
|
//Call the Post class and save the user data to the database
|
|
|
|
$post->title = $title;
|
|
|
|
$post->description = $description;
|
|
|
|
|
|
|
|
//Call the save function.
|
|
|
|
if(!$post->save()){
|
|
|
|
echo "Failed to save the post";
|
|
|
|
exit();
|
|
|
|
}else{
|
2021-06-02 07:23:08 +00:00
|
|
|
header("location: ../../Frontend/home.php?Post=UploadSuccess");
|
2021-06-02 07:01:51 +00:00
|
|
|
}
|
|
|
|
}
|