v0.0.5 Made edit and update
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user