v0.0.10 when you are login in the login button says admin panle, and semi added ajax update post
This commit is contained in:
parent
9f969c4a92
commit
0c6d26d084
|
@ -5,8 +5,8 @@ require "../../bootstrap.php";
|
||||||
|
|
||||||
use Backend\Model\Post;
|
use Backend\Model\Post;
|
||||||
|
|
||||||
if(isset($_GET['delete_id'])){
|
if(isset($_POST['delete_id'])){
|
||||||
$id = $_GET['delete_id'];
|
$id = $_POST['delete_id'];
|
||||||
$findId = Post::query()->findOrFail($id);
|
$findId = Post::query()->findOrFail($id);
|
||||||
if(!$findId->delete()){
|
if(!$findId->delete()){
|
||||||
return "Error could not delete";
|
return "Error could not delete";
|
||||||
|
|
|
@ -4,17 +4,18 @@ require "../../bootstrap.php";
|
||||||
|
|
||||||
use Backend\Model\Post;
|
use Backend\Model\Post;
|
||||||
|
|
||||||
//Create a new initialize
|
if(isset($_POST['title'])){
|
||||||
$post = new Post();
|
//Create a new initialize
|
||||||
|
$post = new Post();
|
||||||
|
|
||||||
//Get the data from post and save it to the post model
|
//Get the data from post and save it to the post model
|
||||||
$post->title = $_POST['title'];
|
$post->title = $_POST['title'];
|
||||||
$post->description = $_POST['description'];
|
$post->description = $_POST['description'];
|
||||||
|
|
||||||
//Call the save function.
|
//Call the save function.
|
||||||
if(!$post->save()){
|
if(!$post->save()){
|
||||||
return http_response_code(400);
|
return http_response_code(400);
|
||||||
}else{
|
}else{
|
||||||
return http_response_code(200);
|
return http_response_code(200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
function deletePost(id) {
|
function deletePost(id) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'get',
|
type: 'POST',
|
||||||
url: '../Backend/controller/deletePost.php',
|
url: '../Backend/controller/deletePost.php',
|
||||||
data: {'delete_id':id},
|
data: {'delete_id':id},
|
||||||
success:function (data) {
|
success:function (data) {
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
function updatePost(id) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '../Backend/controller/update.php',
|
||||||
|
data: {'update_id':id},
|
||||||
|
success:function () {
|
||||||
|
console.log("Update was a success");
|
||||||
|
},
|
||||||
|
error:function (data) {
|
||||||
|
console.log("Update was not a success");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -31,6 +31,8 @@ use Backend\Model\Post;
|
||||||
<body>
|
<body>
|
||||||
<p>Logget in som <?php echo $_SESSION['name'];?></p>
|
<p>Logget in som <?php echo $_SESSION['name'];?></p>
|
||||||
<a href="../Backend/controller/logout.php">Log ud</a>
|
<a href="../Backend/controller/logout.php">Log ud</a>
|
||||||
|
<br>
|
||||||
|
<a href="index.php">Index pages</a>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Opret post</p>
|
<p>Opret post</p>
|
||||||
<!--We use ajax to send the code to the backend-->
|
<!--We use ajax to send the code to the backend-->
|
||||||
|
|
|
@ -20,7 +20,17 @@
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="index.php">Home</a></li>
|
<li class="content__item"><a class="link link--elara text-white" href="index.php">Home</a></li>
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="https://bib.itskp-odense.dk/">Bulltitin Board</a></li>
|
<li class="content__item"><a class="link link--elara text-white" href="https://bib.itskp-odense.dk/">Bulltitin Board</a></li>
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="https://udlaan.itskp-odense.dk/">Udlån af udstyr</a></li>
|
<li class="content__item"><a class="link link--elara text-white" href="https://udlaan.itskp-odense.dk/">Udlån af udstyr</a></li>
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="login.php">Login</a></li>
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (isset($_SESSION['token'])){
|
||||||
|
echo '<li class="content__item"><a class="link link--elara text-white" href="home.php">Admin panel</a></li>';
|
||||||
|
}else{
|
||||||
|
echo '<li class="content__item"><a class="link link--elara text-white" href="login.php">Login</a></li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<input type="checkbox" name="hamburger" id="hamburger" onclick="shownav()"/>
|
<input type="checkbox" name="hamburger" id="hamburger" onclick="shownav()"/>
|
||||||
|
|
|
@ -20,7 +20,17 @@
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="index.php">Home</a></li>
|
<li class="content__item"><a class="link link--elara text-white" href="index.php">Home</a></li>
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="https://bib.itskp-odense.dk/">Bulltitin Board</a></li>
|
<li class="content__item"><a class="link link--elara text-white" href="https://bib.itskp-odense.dk/">Bulltitin Board</a></li>
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="https://udlaan.itskp-odense.dk/">Udlån af udstyr</a></li>
|
<li class="content__item"><a class="link link--elara text-white" href="https://udlaan.itskp-odense.dk/">Udlån af udstyr</a></li>
|
||||||
<li class="content__item"><a class="link link--elara text-white" href="login.php">Login</a></li>
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (isset($_SESSION['token'])){
|
||||||
|
echo '<li class="content__item"><a class="link link--elara text-white" href="home.php">Admin panel</a></li>';
|
||||||
|
}else{
|
||||||
|
echo '<li class="content__item"><a class="link link--elara text-white" href="login.php">Login</a></li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<input type="checkbox" name="hamburger" id="hamburger" onclick="shownav()"/>
|
<input type="checkbox" name="hamburger" id="hamburger" onclick="shownav()"/>
|
||||||
|
|
Loading…
Reference in New Issue