v0.0.3 Made the delete function.

This commit is contained in:
Victor 2021-06-02 09:23:08 +02:00
parent 1bbefdfe08
commit 23a81e1925
3 changed files with 19 additions and 1 deletions

View File

@ -1 +1,17 @@
<?php
require "../../bootstrap.php";
use Backend\Model\Post;
if(isset($_GET['id'])){
$id = $_GET['id'];
$findId = Post::query()->findOrFail($id);
if(!$findId->delete()){
echo "Error could not delete record";
}else{
header("location: ../../Frontend/home.php?recordDeleted");
}
}

View File

@ -22,6 +22,6 @@ if(isset($_POST['createPost'])){
echo "Failed to save the post";
exit();
}else{
echo "Post has been saved";
header("location: ../../Frontend/home.php?Post=UploadSuccess");
}
}

View File

@ -15,5 +15,7 @@
<input type="text" name="description">
<input type="submit" name="createPost" placeholder="Opret">
</form>
<hr>
<a href="../Backend/controller/deletePost.php?id=1" class="del_btn">Delete</a>
</body>
</html>