v0.0.5 Made edit and update
This commit is contained in:
parent
23a81e1925
commit
636672d8f2
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
require "../../bootstrap.php";
|
||||
|
||||
use Backend\Model\Post;
|
||||
|
||||
if(isset($_GET['id'])){
|
||||
$id = $_GET['id'];
|
||||
$post = Post::query()->find($id);
|
||||
|
||||
if($post){
|
||||
echo $post;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
require "../../bootstrap.php";
|
||||
|
||||
use Backend\Model\Post;
|
||||
|
||||
session_start();
|
||||
if (!isset($_SESSION['token'])) {
|
||||
header("location: ../../Frontend/index.php?login=notloggedin");
|
||||
}
|
||||
|
||||
|
||||
header('Content-Type: application/json;charset=UTF-8');
|
||||
echo "<pre>";
|
||||
$data = Post::all();
|
||||
|
||||
echo $data;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
require "../../bootstrap.php";
|
||||
|
||||
use Backend\Model\Post;
|
||||
|
||||
if(isset($_POST['update'])){
|
||||
$id = $_POST['id'];
|
||||
$title = $_POST['upTitle'];
|
||||
$description = $_POST['upDescription'];
|
||||
$post = Post::query()->find($id)->first();
|
||||
$post->title = $title;
|
||||
$post->description = $description;
|
||||
|
||||
if(!$post->update()){
|
||||
echo "Error could not update";
|
||||
}else{
|
||||
header("location: ../../Frontend/home.php");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
require "../Backend/controller/accessControl.php";
|
||||
//require "../Backend/controller/edit.php";//Bootstrap is require via this file
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Home</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="../Backend/controller/update.php" method="POST">
|
||||
<input type="number" name="id" hidden value="1">
|
||||
<input type="text" name="upTitle" placeholder="Title">
|
||||
<input type="text" name="upDescription" placeholder="Description">
|
||||
<input type="submit" name="update">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
<?php require "../Backend/controller/accessControl.php"?>
|
||||
<?php
|
||||
require "../Backend/controller/accessControl.php";
|
||||
require "../bootstrap.php";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
@ -6,16 +9,25 @@
|
|||
<title>Home</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Logget in som <?php echo $_SESSION['name'];?></p>
|
||||
<a href="../Backend/controller/logout.php">Log ud</a>
|
||||
<hr>
|
||||
<p>Opret post</p>
|
||||
<form action="../Backend/controller/upload.php" method="POST">
|
||||
<input type="text" name="title">
|
||||
<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>
|
||||
<p>Slet post</p>
|
||||
<?php
|
||||
$posts = \Backend\Model\Post::all()->pluck('id');
|
||||
foreach ($posts as $post){
|
||||
echo "<a href='../Backend/controller/deletePost.php?id=1'>Delete</a> <br>";
|
||||
}
|
||||
?>
|
||||
<hr>
|
||||
<p>Edit post</p>
|
||||
<a href='edit.php?id=1'>Edit 1</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue