v0.0.7 Try to get ajax to work with backend

This commit is contained in:
Victor
2021-06-04 11:13:38 +02:00
parent 4024c0dd99
commit c7fa37a3ae
4 changed files with 39 additions and 17 deletions
+5 -10
View File
@@ -6,22 +6,17 @@ 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;
//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()){
echo "Failed to save the post";
exit();
return http_response_code(400);
}else{
header("location: ../../Frontend/home.php?Post=UploadSuccess");
return http_response_code(200);
}
}