itskp-odense/Backend/controller/upload.php

23 lines
559 B
PHP

<?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'])){
//Create a new initialize
$post = new Post();
//Get the data from post and save it to the post model
$post->title = $_POST['title'];
$post->description = $_POST['description'];
//Call the save function.
if(!$post->save()){
return http_response_code(400);
}else{
return http_response_code(200);
}
}