Responsive-blog-web/app-admin-panel-completed
36
admin/add-category-logic.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'config/database.php';
|
||||||
|
|
||||||
|
if(isset($_POST['submit'])){
|
||||||
|
//get form data
|
||||||
|
$title =filter_var($_POST['title'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$description=filter_var($_POST['description'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
|
||||||
|
if(!$title){
|
||||||
|
$_SESSION['add-category'] = "Enter title";
|
||||||
|
|
||||||
|
}elseif(!$description){
|
||||||
|
$_SESSION['add-category']="Enter description";
|
||||||
|
|
||||||
|
}
|
||||||
|
// redirect back to add category page if there was invalid input
|
||||||
|
if(isset($_SESSION['add-category'])){
|
||||||
|
$_SESSION['add-category-data'] = $_POST;
|
||||||
|
header('location: ' . ROOT_URL . 'admin/add-category.php');
|
||||||
|
die();
|
||||||
|
}else{
|
||||||
|
// insert category into database
|
||||||
|
$query = "INSERT INTO categories (title , description) VALUES ('$title','$description')";
|
||||||
|
$result = mysqli_query($connection, $query);
|
||||||
|
if(mysqli_errno($connection)){
|
||||||
|
$_SESSION['add-category'] = "Couldn't add category";
|
||||||
|
header('location: ' . ROOT_URL . 'admin/add-category.php');
|
||||||
|
die();
|
||||||
|
}else{
|
||||||
|
$_SESSION['add-category-success'] = "Category $title category added successfully";
|
||||||
|
header('location: ' . ROOT_URL . 'admin/manage-categories.php');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
$title = $_SESSION["add-category-data"]['title'] ?? null;
|
||||||
|
$description = $_SESSION["add-category-data"]['description'] ?? null;
|
||||||
|
|
||||||
|
unset($_SESSION['add-category-data'])
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section class="form__section">
|
<section class="form__section">
|
||||||
|
|
||||||
<div class="container form__section-container">
|
<div class="container form__section-container">
|
||||||
<h2>Add Category</h2>
|
<h2>Add Category</h2>
|
||||||
|
<?php if(isset($_SESSION['add-category'])): ?>
|
||||||
<div class="alert__message error">
|
<div class="alert__message error">
|
||||||
<p>This is an error message</p>
|
<p><?=$_SESSION['add-category'];
|
||||||
|
unset($_SESSION['add-category']);
|
||||||
|
?></p>
|
||||||
</div>
|
</div>
|
||||||
<form action="">
|
<?php endif?>
|
||||||
<input type="text" placeholder="Title">
|
<form action="<?= ROOT_URL ?>admin/add-category-logic.php" method="POST">
|
||||||
<textarea rows="4" placeholder="Description"></textarea>
|
<input type="text" name="title" value = "<?=$title?>"placeholder="Title">
|
||||||
|
<textarea rows="4" name="description" value = "<?=$description?>"placeholder="Description"></textarea>
|
||||||
|
|
||||||
<button type="submit" class="btn">Add Category</button>
|
<button type="submit" name="submit" class="btn">Add Category</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
84
admin/add-post-logic.php
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
require "config/database.php";
|
||||||
|
|
||||||
|
if(isset($_POST['submit'])){
|
||||||
|
$author_id=$_SESSION['user-id'];
|
||||||
|
$title =filter_var($_POST['title'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$body =filter_var($_POST['body'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$category_id =filter_var($_POST['category_id'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$is_featured =filter_var($_POST['is_featured'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$thumbnail =$_FILES['thumbnail'];
|
||||||
|
|
||||||
|
//set featured set to zero if unchecked
|
||||||
|
$is_featured=$is_featured==1 ?:0;
|
||||||
|
|
||||||
|
//validate form data
|
||||||
|
if(!$title){
|
||||||
|
$_SESSION['add-post']="Enter post Title";
|
||||||
|
}elseif(!$category_id){
|
||||||
|
$_SESSION['add-post']="Select post category";
|
||||||
|
|
||||||
|
}elseif(!$body){
|
||||||
|
$_SESSION['add-post']="Enter post body";
|
||||||
|
|
||||||
|
}elseif(!$thumbnail['name']){
|
||||||
|
$_SESSION['add-post']="Choose post thumbnail";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//work on thumbnail
|
||||||
|
//rename the image
|
||||||
|
$time=time();// make each name unique
|
||||||
|
$thumbnail_name=$time . $thumbnail['name'];
|
||||||
|
$thumbnail_tmp_name=$thumbnail['tmp_name'];
|
||||||
|
$thumbnail_destination_path="../images/" . $thumbnail_name;
|
||||||
|
|
||||||
|
//make sure file is an image
|
||||||
|
$allowed_files=['jpg','png','jpeg'];
|
||||||
|
$extension=explode('.',$thumbnail_name);
|
||||||
|
$extension=end($extension);
|
||||||
|
if(in_array($extension,$allowed_files)){
|
||||||
|
//make sure image is not too large.(2mb+)
|
||||||
|
if($thumbnail['size']<2000000){
|
||||||
|
//upload thumbnail
|
||||||
|
move_uploaded_file($thumbnail_tmp_name,$thumbnail_destination_path);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$_SESSION['add-post']="File size too big. Should be less than 2mb";
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$_SESSION['add-post']="File should be png, jpg or jpeg";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// redirect with form data
|
||||||
|
if(isset($_SESSION['add-post'])){
|
||||||
|
$_SESSION['add-post-data']=$_POST;
|
||||||
|
header('location: ' . ROOT_URL . 'admin/add-post.php');
|
||||||
|
die();
|
||||||
|
}else{
|
||||||
|
//set is_featured of all post is set to 0 if is_featured for this post is set to 1
|
||||||
|
if($is_featured==1){
|
||||||
|
$zero_all_is_featured_query="UPDATE posts SET is_featured=0";
|
||||||
|
$zero_all_is_featured_result=mysqli_query($connection,$zero_all_is_featured_query);
|
||||||
|
}
|
||||||
|
//insert post into database
|
||||||
|
$query="INSERT INTO posts (title, body, thumbnail, category_id, author_id, is_featured) VALUES ('$title', '$body', '$thumbnail_name', $category_id , $author_id, $is_featured)";
|
||||||
|
$result=mysqli_query($connection,$query);
|
||||||
|
if(mysqli_errno($connection)){
|
||||||
|
$_SESSION['add-post']="Failed to add post";
|
||||||
|
header("location: " . ROOT_URL . 'admin/index.php');
|
||||||
|
die();
|
||||||
|
}else{
|
||||||
|
$_SESSION['add-post-success']="New post added successfully";
|
||||||
|
header("location: " . ROOT_URL . 'admin/index.php');
|
||||||
|
die();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
header("location: " . ROOT_URL . 'admin/index.php');
|
||||||
|
die();
|
||||||
|
?>
|
|
@ -1,5 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
|
||||||
|
// fetch categories from database
|
||||||
|
$query = "SELECT * FROM categories";
|
||||||
|
$categories=mysqli_query($connection,$query);
|
||||||
|
|
||||||
|
// get back form data if form was invalid
|
||||||
|
|
||||||
|
$title= $_SESSION['add-post-data']['title'] ?? null;
|
||||||
|
$body= $_SESSION['add-post-data']['body'] ?? null;
|
||||||
|
unset($_SESSION['add-post-data']);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,35 +17,40 @@ include "partials/header.php";
|
||||||
<section class="form__section">
|
<section class="form__section">
|
||||||
<div class="container form__section-container">
|
<div class="container form__section-container">
|
||||||
<h2>Add Post</h2>
|
<h2>Add Post</h2>
|
||||||
|
<?php if(isset($_SESSION['add-post'])) : ?>
|
||||||
<div class="alert__message error">
|
<div class="alert__message error">
|
||||||
<p>This is an error message</p>
|
<p>
|
||||||
|
<?=
|
||||||
|
$_SESSION['add-post'];
|
||||||
|
unset($_SESSION['add-post']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<form action="" enctype="multipart/form-data">
|
<?php endif ?>
|
||||||
<input type="text" placeholder="Title">
|
<form action="<?= ROOT_URL ?>admin/add-post-logic.php" enctype="multipart/form-data" method="POST">
|
||||||
<select >
|
<input type="text" name="title" value ="<?= $title ?>" placeholder="Title">
|
||||||
<option value="1">Wild Life</option>
|
<select name="category_id">
|
||||||
<option value="1">Music</option>
|
<?php while($category = mysqli_fetch_assoc($categories)) : ?>
|
||||||
<option value="1">Website</option>
|
<option value="<?= $category['id'] ?>"><?= $category['title'] ?></option>
|
||||||
<option value="1">Movies</option>
|
<?php endwhile?>
|
||||||
<option value="1">Travel</option>
|
|
||||||
<option value="1">Science & Technology</option>
|
|
||||||
<option value="1">Food</option>
|
|
||||||
</select>
|
</select>
|
||||||
|
<?php if(isset($_SESSION["user_is_admin"])) : ?>
|
||||||
<div class="form__control inline">
|
<div class="form__control inline">
|
||||||
<input type="checkbox" id="is_featured" checked>
|
<input type="checkbox" name="is_featured" value='1' id="is_featured" checked>
|
||||||
<label for="is_featured" >Featured</label>
|
<label for="is_featured" >Featured</label>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows="8" placeholder="Body"></textarea>
|
<?php endif ?>
|
||||||
|
<textarea rows="8" name="body" placeholder="Body"><?=$body?></textarea>
|
||||||
|
|
||||||
<div class="form__control">
|
<div class="form__control">
|
||||||
<label for="thumbnail">Add Thumbnail</label>
|
<label for="thumbnail">Add Thumbnail</label>
|
||||||
<input type="file" id="thumbnail">
|
<input type="file" name="thumbnail" id="thumbnail">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn">Add Post</button>
|
<button type="submit" name="submit" class="btn">Add Post</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
include './partials/footer.php';
|
include '../partials/footer.php';
|
||||||
?>
|
?>
|
98
admin/add-user-logic.php
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
<?php
|
||||||
|
require "config/database.php";
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
//get add-user form data if sbmit button is clicked
|
||||||
|
|
||||||
|
if(isset($_POST["submit"])){
|
||||||
|
$firstname = filter_var($_POST['firstname'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$lastname = filter_var($_POST['lastname'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$username = filter_var($_POST['username'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
|
||||||
|
$createpassword = filter_var($_POST['createpassword'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$confirmpassword = filter_var($_POST['confirmpassword'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$is_admin = filter_var($_POST['userrole'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$avatar = $_FILES['avatar'];
|
||||||
|
if(!$firstname){
|
||||||
|
$_SESSION['add-user'] = 'Please enter your First Name';
|
||||||
|
}elseif(!$lastname){
|
||||||
|
$_SESSION['add-user'] = 'Please enter your Last Name';
|
||||||
|
}elseif(!$username){
|
||||||
|
$_SESSION['add-user'] = 'Please enter your Username';
|
||||||
|
}elseif(!$email){
|
||||||
|
$_SESSION['add-user'] = 'Please enter your Email';
|
||||||
|
}elseif(!($is_admin == 1 || $is_admin == 0 )){
|
||||||
|
$_SESSION['add-user'] = 'Please select user role';
|
||||||
|
}elseif(strlen($createpassword)<8 || strlen($confirmpassword)<8){
|
||||||
|
$_SESSION['add-user'] = 'Password should be 8+ characters';
|
||||||
|
}elseif(!$avatar['name']){
|
||||||
|
$_SESSION['add-user'] = 'Please add Avatar ';
|
||||||
|
}else{
|
||||||
|
if($createpassword !== $confirmpassword){
|
||||||
|
$_SESSION['add-user']="Passwords donot match";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
|
||||||
|
$hashed_password = password_hash($createpassword,PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$user_check_query="SELECT * FROM users WHERE username='$username' OR email ='$email'";
|
||||||
|
$user_check_result = mysqli_query($connection, $user_check_query);
|
||||||
|
if(mysqli_num_rows($user_check_result)>0){
|
||||||
|
$_SESSION['add-user'] = "Username or Email already exists";
|
||||||
|
}else{
|
||||||
|
//WORK ON AVATAR
|
||||||
|
//rename avatar
|
||||||
|
$time = time(); // make each image name unique using current timestamp
|
||||||
|
$avatar_name = $time . $avatar['name'];
|
||||||
|
$avatar_tmp_name=$avatar['tmp_name'];
|
||||||
|
$avatar_destination_path='../images/' . $avatar_name;
|
||||||
|
|
||||||
|
//,ake sure file is an image
|
||||||
|
$allowed_files = ['png', 'jpg', 'jpeg'];
|
||||||
|
$extension = explode('.', $avatar_name);
|
||||||
|
$extension = end($extension);
|
||||||
|
|
||||||
|
if(in_array($extension,$allowed_files)){
|
||||||
|
|
||||||
|
//if image not too large
|
||||||
|
if($avatar['size']<1000000){
|
||||||
|
|
||||||
|
//upload avatar
|
||||||
|
move_uploaded_file($avatar_tmp_name, $avatar_destination_path);
|
||||||
|
}else{
|
||||||
|
$_SESSION['add-user']="Folder size too big.Should be less than 1mb";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$_SESSION['add-user']="File should be png, jpg or jpeg";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// redirect back t add-user on error
|
||||||
|
if(isset($_SESSION['add-user'])){
|
||||||
|
// pass data back to sign up page
|
||||||
|
$_SESSION['add-user-data'] = $_POST;
|
||||||
|
header('location: ' . ROOT_URL . 'admin/add-user.php');
|
||||||
|
die();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//insert new user into users table
|
||||||
|
$inset_user_query = "INSERT INTO users SET firstname ='$firstname' ,lastname='$lastname',username='$username',email ='$email' ,password='$hashed_password',avatar='$avatar_name',is_admin='$is_admin'";
|
||||||
|
$inset_user_result = mysqli_query($connection, $inset_user_query);
|
||||||
|
if(!mysqli_errno($connection)){
|
||||||
|
$_SESSION['add-user-success'] = "Registration Successful";
|
||||||
|
header('location: ' . ROOT_URL . 'admin/manage-users.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//button not clicked
|
||||||
|
header('location: ' . ROOT_URL . "admin/add-user.php");
|
||||||
|
die();
|
||||||
|
}
|
|
@ -1,22 +1,57 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
|
||||||
|
//get beck form DATA IF THERE IS A REGISTRATION ERROR
|
||||||
|
$firstname=$_SESSION['add-user-data']['firstname'] ?? null;
|
||||||
|
$lastname=$_SESSION['add-user-data']['lastname'] ?? null;
|
||||||
|
$username=$_SESSION['add-user-data']['username'] ?? null;
|
||||||
|
$email=$_SESSION['add-user-data']['email'] ?? null;
|
||||||
|
$createpassword=$_SESSION['add-user-data']['createpassword'] ?? null;
|
||||||
|
$confirmpassword = $_SESSION['add-user-data']['confirmpassword'] ?? null;
|
||||||
|
|
||||||
|
//delete add-user data session
|
||||||
|
unset($_SESSION['add-user-data']);
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<section class="form__section">
|
<section class="form__section">
|
||||||
<div class="container form__section-container">
|
<div class="container form__section-container">
|
||||||
<h2>Add User</h2>
|
<h2>Add User</h2>
|
||||||
<div class="alert__message error">
|
|
||||||
<p>This is an error message</p>
|
<?php if(isset($_SESSION['add-user-success'])): ?>
|
||||||
|
|
||||||
|
<div class="alert__message success">
|
||||||
|
<p>
|
||||||
|
<?=$_SESSION['add-user-success'];
|
||||||
|
unset($_SESSION['add-user-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<form action="" enctype="multipart/form-data">
|
|
||||||
<input type="text" placeholder="First Name">
|
|
||||||
<input type="text" placeholder="Last Name">
|
<?php elseif(isset($_SESSION['add-user'])): ?>
|
||||||
<input type="text" placeholder="Username">
|
|
||||||
<input type="email" placeholder="Email">
|
<div class="alert__message error">
|
||||||
<input type="password" placeholder="Create Password">
|
<p>
|
||||||
<input type="password" placeholder="Confirm Password">
|
<?=$_SESSION['add-user'];
|
||||||
<select>
|
unset($_SESSION['add-user']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
|
||||||
|
<form action="<?=ROOT_URL?>admin/add-user-logic.php" enctype="multipart/form-data" method='POST'>
|
||||||
|
<input type="text" name ="firstname" value ="<?= $firstname?>" placeholder="First Name">
|
||||||
|
<input type="text" name ="lastname" value ="<?= $lastname?>" placeholder="Last Name">
|
||||||
|
<input type="username" name ="username" value ="<?= $username ?>" placeholder="Username">
|
||||||
|
<input type="email" name ="email" value ="<?= $email ?>" placeholder="email">
|
||||||
|
<input type="password" name ="createpassword" value ="<?= $createpassword ?>" placeholder="Password">
|
||||||
|
<input type="password" name ="confirmpassword" value ="<?= $confirmpassword?>" placeholder="Confirm Password">
|
||||||
|
<select name='userrole'>
|
||||||
|
|
||||||
<option value="0">Author</option>
|
<option value="0">Author</option>
|
||||||
<option value="1">Admin</option>
|
<option value="1">Admin</option>
|
||||||
|
@ -24,9 +59,9 @@ include "partials/header.php";
|
||||||
</select>
|
</select>
|
||||||
<div class="form__control">
|
<div class="form__control">
|
||||||
<label for="avatar">User Avatar</label>
|
<label for="avatar">User Avatar</label>
|
||||||
<input type="file" id="avatar">
|
<input type="file" name ='avatar' id="avatar">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn">Add User</button>
|
<button type="submit" name='submit' class="btn">Add User</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -36,5 +71,5 @@ include "partials/header.php";
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
include './partials/footer.php';
|
include '../partials/footer.php';
|
||||||
?>
|
?>
|
27
admin/delete-category.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
include "config/database.php";
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id=filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
|
||||||
|
// update id of post that belong to this category as uncategorized
|
||||||
|
$update_query="UPDATE posts SET category_id=2 WHERE category_id=$id";
|
||||||
|
$update_result=mysqli_query($connection,$update_query);
|
||||||
|
|
||||||
|
if(!mysqli_errno($connection)){
|
||||||
|
//delete category
|
||||||
|
$query="DELETE FROM categories WHERE id='$id' LIMIT 1";
|
||||||
|
$result= mysqli_query($connection,$query);
|
||||||
|
$_SESSION['edit-category-success']="Category was deleted successfuly";
|
||||||
|
header("location: " . ROOT_URL . "admin/manage-categories.php");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
header("location: " . ROOT_URL . "admin/manage-categories.php");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
?>
|
36
admin/delete-post.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
require 'config/database.php';
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id=filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
|
||||||
|
// fetch post fom database
|
||||||
|
$query="SELECT * FROM posts WHERE id=$id";
|
||||||
|
$result =mysqli_query($connection,$query);
|
||||||
|
|
||||||
|
//make sure 1 record was fetched from database
|
||||||
|
if(mysqli_num_rows($result)==1){
|
||||||
|
$post=mysqli_fetch_assoc($result);
|
||||||
|
$thumbnail_name=$post['thumbnail'];
|
||||||
|
$thumbnail_path="../images/" . $thumbnail_name;
|
||||||
|
|
||||||
|
if($thumbnail_path){
|
||||||
|
unlink($thumbnail_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete post from database
|
||||||
|
$delete_post_query="DELETE from posts WHERE id=$id LIMIT 1";
|
||||||
|
$delete_post_result=mysqli_query($connection,$delete_post_query);
|
||||||
|
|
||||||
|
if(!mysqli_errno($connection)){
|
||||||
|
$_SESSION['edit-post-success']="Post deleted successfully";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
header('location: ' . ROOT_URL . 'admin/');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
header('location: ' . ROOT_URL . 'admin/');
|
||||||
|
die();
|
54
admin/delete-users.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'config/database.php';
|
||||||
|
if(!(isset($_SESSION['user_is_admin']))){
|
||||||
|
header("location :".ROOT_URL."logout.php");
|
||||||
|
|
||||||
|
}elseif(isset($_GET["id"])){
|
||||||
|
$id =filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
//fetch user from database
|
||||||
|
$query="SELECT * FROM users WHERE id=$id";
|
||||||
|
$result=mysqli_query($connection,$query);
|
||||||
|
$user = mysqli_fetch_assoc($result);
|
||||||
|
//make sure we got back only one user
|
||||||
|
if(mysqli_num_rows($result)==1){
|
||||||
|
$avatar_name = $user['avatar'];
|
||||||
|
$avatar_path = '../images/' . $avatar_name;
|
||||||
|
//delete if image available
|
||||||
|
if($avatar_path){
|
||||||
|
unlink($avatar_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for later
|
||||||
|
// fetch all thumbnails of user's post and delete them
|
||||||
|
$thumbnails_query="SELECT thumbnail FROM posts WHERE author_id=$id";
|
||||||
|
$thumbnails_result=mysqli_query($connection,$thumbnails_query);
|
||||||
|
if(mysqli_num_rows($thumbnails_result)>1){
|
||||||
|
while($thumbnail=mysqli_fetch_assoc($thumbnails_result)){
|
||||||
|
$thumbnail_path="../images/" . $thumbnail['thumbnail'];
|
||||||
|
if($thumbnail_path){
|
||||||
|
unlink($thumbnail_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// delete user from database
|
||||||
|
$delete_user_query = "DELETE FROM users WHERE id = $id";
|
||||||
|
$delete_user_result = mysqli_query($connection, $delete_user_query);
|
||||||
|
if(mysqli_errno($connection)){
|
||||||
|
$_SESSION['delete-user']="Couldn't delete '{$user['firstname']}' '{$user['lastname']}'";
|
||||||
|
|
||||||
|
} else{
|
||||||
|
$_SESSION['delete-user-success']="'{$user['firstname']} {$user['lastname']}' has been deleted successfully";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
header("location: " . ROOT_URL . "admin/manage-users.php");
|
||||||
|
die();
|
25
admin/edit-category-logic.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
require "config/database.php";
|
||||||
|
|
||||||
|
if(isset($_POST['submit'])){
|
||||||
|
$id = filter_var($_POST['id'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$title=filter_var($_POST['title'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$description = filter_var($_POST['description'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
|
||||||
|
if(!$title || !$description){
|
||||||
|
$_SESSION['edit-category'] = "Invalid form input on edit category page";
|
||||||
|
}else{
|
||||||
|
$query = "UPDATE categories SET title='$title',description='$description' WHERE id=$id LIMIT 1";
|
||||||
|
$result=mysqli_query($connection, $query);
|
||||||
|
|
||||||
|
if(mysqli_errno($connection)){
|
||||||
|
$_SESSION['edit-category'] = "Couldnt update category";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$_SESSION['edit-category-success'] = "$title Category was updated successfully";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
header('location: ' . ROOT_URL . "admin/manage-categories.php");
|
||||||
|
die();
|
|
@ -1,5 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id=filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
|
||||||
|
// fetch category from database
|
||||||
|
$query="SELECT * FROM categories WHERE id=$id";
|
||||||
|
$result=mysqli_query($connection,$query);
|
||||||
|
if(mysqli_num_rows($result)==1){
|
||||||
|
$category = mysqli_fetch_assoc($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
header("location: " . ROOT_URL . "admin/manage-categories.php");
|
||||||
|
die();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,11 +22,12 @@ include "partials/header.php";
|
||||||
|
|
||||||
<div class="container form__section-container" >
|
<div class="container form__section-container" >
|
||||||
<h2>Edit Category</h2>
|
<h2>Edit Category</h2>
|
||||||
<form action="">
|
<form action="<?= ROOT_URL ?>admin/edit-category-logic.php" method="POST">
|
||||||
<input type="text" placeholder="Title">
|
<input type="hidden" name="id" value="<?=$category['id']?>">
|
||||||
<textarea rows="4" placeholder="Description"></textarea>
|
<input type="text" name="title" value="<?=$category['title']?>" placeholder="Title">
|
||||||
|
<textarea rows="4" name="description" placeholder="Description"><?=$category['description']?></textarea>
|
||||||
|
|
||||||
<button type="submit" class="btn">Update Category</button>
|
<button type="submit" name ="submit" class="btn">Update Category</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
84
admin/edit-post-logic.php
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
require 'config/database.php';
|
||||||
|
if(isset($_POST['submit'])){
|
||||||
|
$id=filter_var($_POST['id'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$is_featured=filter_var($_POST['is_featured'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$title=filter_var($_POST['title'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$body=filter_var($_POST['body'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$previous_thumbnail_name=filter_var($_POST['previous_thumbnail_name'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$category_id=filter_var($_POST['category_id'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$thumbnail=$_FILES['thumbnail'];
|
||||||
|
|
||||||
|
//set featured to zero if unchecked
|
||||||
|
$is_featured=$is_featured == 1 ?: 0;
|
||||||
|
|
||||||
|
//check and validate input values
|
||||||
|
if(!$title){
|
||||||
|
$_SESSION['edit-post']="Couldnt update post. Invalid form data on edit page.";
|
||||||
|
}elseif(!$category_id){
|
||||||
|
$_SESSION['edit-post']="Couldnt update post. Invalid form data on edit page.";
|
||||||
|
}elseif(!$body){
|
||||||
|
$_SESSION['edit-post']="Couldnt update post. Invalid form data on edit page.";
|
||||||
|
}else{
|
||||||
|
if($thumbnail['name']){
|
||||||
|
$previous_thumbnail_destination='../images/' . $previous_thumbnail_name;
|
||||||
|
if($previous_thumbnail_destination){
|
||||||
|
unlink($previous_thumbnail_destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
// WORK ON NEW THUMBNAIL
|
||||||
|
//rename image
|
||||||
|
|
||||||
|
$time=time();
|
||||||
|
$thumbnail_name=$time . $thumbnail['name'];
|
||||||
|
$thumbnail_tmp_name=$thumbnail['tmp_name'];
|
||||||
|
$thumbnail_destination_path="../images/" . $thumbnail_name;
|
||||||
|
|
||||||
|
//make sure file is an image
|
||||||
|
$allowed_files=['jpg','png','jpeg'];
|
||||||
|
$extension=explode('.',$thumbnail_name);
|
||||||
|
$extension=end($extension);
|
||||||
|
if(in_array($extension,$allowed_files)){
|
||||||
|
//make sure image is not too large.(2mb+)
|
||||||
|
if($thumbnail['size']<2000000){
|
||||||
|
//upload thumbnail
|
||||||
|
move_uploaded_file($thumbnail_tmp_name,$thumbnail_destination_path);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$_SESSION['edit-post']="File size too big. Should be less than 2mb";
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$_SESSION['edit-post']="File should be png, jpg or jpeg";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// redirect to manage post if there is error in form data
|
||||||
|
if(isset($_SESSION['edit-post'])){
|
||||||
|
|
||||||
|
header('location: ' . ROOT_URL . 'admin/');
|
||||||
|
die();
|
||||||
|
}else{
|
||||||
|
//set is_featured of all post is set to 0 if is_featured for this post is set to 1
|
||||||
|
if($is_featured==1){
|
||||||
|
$zero_all_is_featured_query="UPDATE posts SET is_featured=0";
|
||||||
|
$zero_all_is_featured_result=mysqli_query($connection,$zero_all_is_featured_query);
|
||||||
|
}
|
||||||
|
$thumbnail_to_insert= $thumbnail_name ?? $previous_thumbnail_name;
|
||||||
|
|
||||||
|
|
||||||
|
//insert post into database
|
||||||
|
$query="UPDATE posts SET title='$title', body='$body' ,thumbnail='$thumbnail_to_insert' ,category_id='$category_id',is_featured=$is_featured WHERE id=$id LIMIT 1";
|
||||||
|
$result=mysqli_query($connection,$query);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!mysqli_errno($connection)){
|
||||||
|
$_SESSION['edit-post-success']="Post updated successfully";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
header('location: ' . ROOT_URL . 'admin/');
|
||||||
|
die();
|
|
@ -1,33 +1,44 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
|
||||||
|
|
||||||
|
$category_query = "SELECT * FROM categories";
|
||||||
|
$categories=mysqli_query($connection,$category_query);
|
||||||
|
|
||||||
|
// fetch post data from database if id is set
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id=filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$query="SELECT * FROM posts WHERE id= $id";
|
||||||
|
$result=mysqli_query($connection,$query);
|
||||||
|
$post=mysqli_fetch_assoc($result);
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section class="form__section">
|
<section class="form__section">
|
||||||
<div class="container form__section-container">
|
<div class="container form__section-container">
|
||||||
<h2>Edit Post</h2>
|
<h2>Edit Post</h2>
|
||||||
|
<form action="<?= ROOT_URL ?>admin/edit-post-logic.php" enctype="multipart/form-data" method="POST">
|
||||||
<form action="" enctype="multipart/form-data">
|
<input type="text" value="<?=$post['title']?>" name ="title" placeholder="Title">
|
||||||
<input type="text" placeholder="Title">
|
<input type="hidden" value="<?=$post['id']?>" name="id">
|
||||||
<select >
|
<input type="hidden" value="<?=$post['thumbnail']?>" name="previous_thumbnail_name">
|
||||||
<option value="1">Wild Life</option>
|
<select name="category_id">
|
||||||
<option value="1">Music</option>
|
<?php while ($category=mysqli_fetch_assoc($categories)) :?>
|
||||||
<option value="1">Website</option>
|
<option value='<?= $category['id']?>'><?= $category['title'] ?></option>
|
||||||
<option value="1">Movies</option>
|
<?php endwhile ?>
|
||||||
<option value="1">Travel</option>
|
|
||||||
<option value="1">Science & Technology</option>
|
|
||||||
<option value="1">Food</option>
|
|
||||||
</select>
|
</select>
|
||||||
|
<?php if(isset($_SESSION['user_is_admin'])) : ?>
|
||||||
<div class="form__control inline">
|
<div class="form__control inline">
|
||||||
<input type="checkbox" id="is_featured" checked>
|
<input type="checkbox" id="is_featured" name="is_featured" value="1" checked>
|
||||||
<label for="is_featured" >Featured</label>
|
<label for="is_featured" >Featured</label>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows="8" placeholder="Body"></textarea>
|
<?php endif?>
|
||||||
|
<textarea rows="8" name="body" placeholder="Body"><?=$post['body']?></textarea>
|
||||||
|
|
||||||
<div class="form__control">
|
<div class="form__control">
|
||||||
<label for="thumbnail">Change Thumbnail</label>
|
<label for="thumbnail" value="">Change Thumbnail</label>
|
||||||
<input type="file" id="thumbnail">
|
<input type="file" name ="thumbnail" id="thumbnail">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn">Update Post</button>
|
<button type="submit" name="submit" class="btn">Update Post</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
38
admin/edit-user-logic.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
require "config/database.php";
|
||||||
|
|
||||||
|
if(!isset($_SESSION['user_is_admin'])){
|
||||||
|
header("location: " . ROOT_URL . "logout.php");
|
||||||
|
//destroy all sessions and redirect user to login page
|
||||||
|
session_destroy();
|
||||||
|
}
|
||||||
|
if(isset($_POST['submit'])){
|
||||||
|
//get updated form data
|
||||||
|
$id = filter_var($_POST['id'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$firstname = filter_var($_POST['firstname'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$lastname = filter_var($_POST['lastname'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$is_admin = filter_var($_POST['userrole'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
|
||||||
|
//check for valid input
|
||||||
|
if(!$firstname || !$lastname ){
|
||||||
|
$_SESSION['edit-user'] = "Invalid form input on edit page";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//update user
|
||||||
|
$query = "UPDATE users SET firstname='$firstname', lastname='$lastname',is_admin=$is_admin WHERE id= $id LIMIT 1";
|
||||||
|
$result = mysqli_query($connection, $query);
|
||||||
|
|
||||||
|
if(mysqli_errno($connection)){
|
||||||
|
$_SESSION['edit-user'] = 'Failed to update user';
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$_SESSION['edit-user-success'] = "User $firstname $lastname updated successfully";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
header("location: " . ROOT_URL . "admin/manage-users.php");
|
||||||
|
die();
|
||||||
|
?>
|
|
@ -1,21 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
if(!isset($_SESSION['user_is_admin'])){
|
||||||
|
header("location: " . ROOT_URL . "logout.php");
|
||||||
|
//destroy all sessions and redirect user to login page
|
||||||
|
session_destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$query = "SELECT firstname,lastname FROM users WHERE id='$id'";
|
||||||
|
$result = mysqli_query($connection, $query);
|
||||||
|
$user = mysqli_fetch_assoc($result);
|
||||||
|
}else{
|
||||||
|
header('location: ' . ROOT_URL . 'admin/manage-users.php');
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section class="form__section">
|
<section class="form__section">
|
||||||
<div class="container form__section-container">
|
<div class="container form__section-container">
|
||||||
<h2>Edit User</h2>
|
<h2>Edit User</h2>
|
||||||
|
|
||||||
<form action="" enctype="multipart/form-data">
|
<form action="<?=ROOT_URL?>admin/edit-user-logic.php" enctype="multipart/form-data" method ="POST">
|
||||||
<input type="text" placeholder="First Name">
|
<input type="hidden" value="<?=$id?>" name='id'>
|
||||||
<input type="text" placeholder="Last Name">
|
<input type="text" name ="firstname" value="<?= $user['firstname'] ?>" placeholder="First Name">
|
||||||
<select>
|
<input type="text" name ="lastname" value="<?= $user['lastname'] ?>" placeholder="Last Name">
|
||||||
|
<select name ="userrole" >
|
||||||
|
|
||||||
<option value="0" >Author</option>
|
<option value="0" >Author</option>
|
||||||
<option value="1">Admin</option>
|
<option value="1">Admin</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<button type="submit" class="btn">Update User</button>
|
<button type="submit" name="submit" class="btn">Update User</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -1,9 +1,60 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
|
||||||
|
// fetch curretn user-id from session
|
||||||
|
$current_user_id=$_SESSION['user-id'];
|
||||||
|
$query="SELECT id , title ,category_id FROM posts WHERE author_id=$current_user_id ORDER BY id DESC" ;
|
||||||
|
$posts = mysqli_query($connection,$query);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<section class="dashboard">
|
<section class="dashboard">
|
||||||
|
<?php if(isset($_SESSION['signin-success'])): ?>
|
||||||
|
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?=$_SESSION['signin-success'];
|
||||||
|
unset($_SESSION['signin-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php elseif(isset($_SESSION['add-post'])): ?>
|
||||||
|
|
||||||
|
<div class="alert__message error container">
|
||||||
|
<p>
|
||||||
|
<?=$_SESSION['add-post'];
|
||||||
|
unset($_SESSION['add-post']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php elseif(isset($_SESSION['add-post-success'])): ?>
|
||||||
|
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?=$_SESSION['add-post-success'];
|
||||||
|
unset($_SESSION['add-post-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php elseif(isset($_SESSION['edit-post'])): ?>
|
||||||
|
|
||||||
|
<div class="alert__message error container">
|
||||||
|
<p>
|
||||||
|
<?=$_SESSION['edit-post'];
|
||||||
|
unset($_SESSION['edit-post']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php elseif(isset($_SESSION['edit-post-success'])): ?>
|
||||||
|
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?=$_SESSION['edit-post-success'];
|
||||||
|
unset($_SESSION['edit-post-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
<div class="container dashboard__container">
|
<div class="container dashboard__container">
|
||||||
|
|
||||||
<button id="show__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-right-b"></i></button>
|
<button id="show__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-right-b"></i></button>
|
||||||
|
@ -56,35 +107,37 @@ include "partials/header.php";
|
||||||
<main>
|
<main>
|
||||||
<h2>Manage Posts</h2>
|
<h2>Manage Posts</h2>
|
||||||
<table>
|
<table>
|
||||||
|
<?php if ((mysqli_num_rows($posts)) > 0 ): ?>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
|
<th>Category</th>
|
||||||
<th>Edit</th>
|
<th>Edit</th>
|
||||||
<th>Delete</th>
|
<th>Delete</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<?php while($post = mysqli_fetch_assoc($posts)) : ?>
|
||||||
|
<!-- get category title of each post from category table -->
|
||||||
|
<?php
|
||||||
|
$category_id=$post['category_id'];
|
||||||
|
$category_query="SELECT title FROM categories WHERE id=$category_id";
|
||||||
|
$category_result=mysqli_query($connection,$category_query);
|
||||||
|
$category=mysqli_fetch_assoc($category_result);
|
||||||
|
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo, minus.</td>
|
<td><?=$post['title']?></td>
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-post.php" class="btn sm">Edit</a></td>
|
<td><?=$category['title']?></td>
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
<td><a href="<?= ROOT_URL ?>admin/edit-post.php?id=<?= $post['id'] ?>" class="btn sm">Edit</a></td>
|
||||||
</tr>
|
<td><a href="<?= ROOT_URL ?>admin/delete-post.php?id=<?= $post['id'] ?>" class="btn sm danger">Delete</a></td>
|
||||||
<tr>
|
|
||||||
<td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore, corrupti!</td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-post.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Lorem ipsum dolor sit amet elit. Distinctio, quibusdam!</td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-post.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Lorem ipsum dolor sit amet consectetur, adipisicing elit.</td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-post.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php endwhile ?>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<?php else :?>
|
||||||
|
<div class="alert alert__message error"><?= "No posts found" ?></div>
|
||||||
|
<?php endif?>
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,54 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
|
||||||
|
//fetch categories from database
|
||||||
|
$query = "SELECT * FROM categories ORDER BY title";
|
||||||
|
$categories=mysqli_query($connection,$query)
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<section class="dashboard">
|
<section class="dashboard">
|
||||||
|
<?php if(isset($_SESSION['add-category-success'])) : ?>
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['add-category-success'];
|
||||||
|
unset($_SESSION['add-category-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
elseif(isset($_SESSION['add-category'])): ?>
|
||||||
|
<div class="alert__message error container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['add-category'];
|
||||||
|
unset($_SESSION['add-category']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php endif?>
|
||||||
|
<?php if(isset($_SESSION['edit-category-success'])) : ?>
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['edit-category-success'];
|
||||||
|
unset($_SESSION['edit-category-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
elseif(isset($_SESSION['edit-category'])): ?>
|
||||||
|
<div class="alert__message error container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['edit-category'];
|
||||||
|
unset($_SESSION['edit-category']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php endif?>
|
||||||
<div class="container dashboard__container">
|
<div class="container dashboard__container">
|
||||||
|
|
||||||
<button id="show__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-right-b"></i></button>
|
<button id="show__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-right-b"></i></button>
|
||||||
|
@ -55,6 +100,7 @@ include "partials/header.php";
|
||||||
</aside>
|
</aside>
|
||||||
<main>
|
<main>
|
||||||
<h2>Manage Categories</h2>
|
<h2>Manage Categories</h2>
|
||||||
|
<?php if(mysqli_num_rows($categories)>0) : ?>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -64,22 +110,19 @@ include "partials/header.php";
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<?php while($category=mysqli_fetch_assoc($categories)) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Travel</td>
|
<td><?=$category['title']?></td>
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-category.php" class="btn sm">Edit</a></td>
|
<td><a href="<?= ROOT_URL ?>admin/edit-category.php?id=<?=$category['id']?>" class="btn sm">Edit</a></td>
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
<td><a href="<?= ROOT_URL ?>admin/delete-category.php?id=<?=$category['id']?>" class="btn sm danger">Delete</a></td>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Music</td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-category.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Wild Life</td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-category.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php endwhile ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<?php else : ?>
|
||||||
|
<div class="alert__message error">
|
||||||
|
No categories found
|
||||||
|
</div>
|
||||||
|
<?php endif?>
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,71 @@
|
||||||
<?php
|
<?php
|
||||||
include "partials/header.php";
|
include "partials/header.php";
|
||||||
|
|
||||||
|
|
||||||
|
$current_admin_id = $_SESSION['user-id'];
|
||||||
|
|
||||||
|
$query="SELECT id,firstname,lastname,username,is_admin FROM users WHERE NOT id='$current_admin_id'";
|
||||||
|
$users=mysqli_query($connection,$query);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<section class="dashboard">
|
<section class="dashboard">
|
||||||
|
<?php
|
||||||
|
if(isset($_SESSION['add-user-success'])):
|
||||||
|
?>
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['add-user-success'];
|
||||||
|
unset($_SESSION['add-user-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
elseif(isset($_SESSION['edit-user'])):
|
||||||
|
?>
|
||||||
|
<div class="alert__message error container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['edit-user'];
|
||||||
|
unset($_SESSION['edit-user']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
elseif(isset($_SESSION['edit-user-success'])):
|
||||||
|
?>
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['edit-user-success'];
|
||||||
|
unset($_SESSION['edit-user-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
elseif(isset($_SESSION['delete-user'])):
|
||||||
|
?>
|
||||||
|
<div class="alert__message error container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['delete-user'];
|
||||||
|
unset($_SESSION['delete-user']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
elseif(isset($_SESSION['delete-user-success'])):
|
||||||
|
?>
|
||||||
|
<div class="alert__message success container">
|
||||||
|
<p>
|
||||||
|
<?= $_SESSION['delete-user-success'];
|
||||||
|
unset($_SESSION['delete-user-success']);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
<div class="container dashboard__container">
|
<div class="container dashboard__container">
|
||||||
|
|
||||||
<button id="show__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-right-b"></i></button>
|
<button id="show__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-right-b"></i></button>
|
||||||
|
@ -56,6 +118,7 @@ include "partials/header.php";
|
||||||
</aside>
|
</aside>
|
||||||
<main>
|
<main>
|
||||||
<h2>Manage Users</h2>
|
<h2>Manage Users</h2>
|
||||||
|
<?php if(mysqli_num_rows($users)>0): ?>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -67,31 +130,23 @@ include "partials/header.php";
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<?php while($user=mysqli_fetch_assoc($users)): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= $user["firstname"] . $user['lastname'] ?></td>
|
||||||
|
<td><?= $user["username"] ?> </td>
|
||||||
|
<td><a href="<?= ROOT_URL ?>admin/edit-user.php?id=<?= $user['id'] ?>" class="btn sm">Edit</a></td>
|
||||||
|
<td><a href="<?= ROOT_URL ?>admin/delete-users.php?id=<?= $user['id'] ?>" class="btn sm danger">Delete</a></td>
|
||||||
|
<td><?= $user["is_admin"] ? 'Yes' : 'No' ?></td>
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>Named Guy</td>
|
|
||||||
<td>Named </td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-user.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
<td>Yes</td>
|
|
||||||
<tr>
|
|
||||||
<td>Vinland Saga </td>
|
|
||||||
<td>Saga </td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-user.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
<td>No</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Pikachu Guy</td>
|
|
||||||
<td>Guy </td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/edit-user.php" class="btn sm">Edit</a></td>
|
|
||||||
<td><a href="<?= ROOT_URL ?>admin/delete-category.php" class="btn sm danger">Delete</a></td>
|
|
||||||
<td>Yes</td>
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php endwhile ?>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php else : ?>
|
||||||
|
<div class="alert__message error">No users found</div>
|
||||||
|
<?php endif?>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
335
blog.php
|
@ -1,12 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
include 'partials/header.php'
|
include 'partials/header.php';
|
||||||
|
|
||||||
|
|
||||||
|
//featured
|
||||||
|
$featured_query="SELECT * FROM posts WHERE is_featured=1";
|
||||||
|
$featured_result=mysqli_query($connection,$featured_query);
|
||||||
|
$featured=mysqli_fetch_assoc($featured_result);
|
||||||
|
|
||||||
|
//fetch 9post
|
||||||
|
|
||||||
|
|
||||||
|
$query="SELECT * FROM posts ORDER BY date_time DESC";
|
||||||
|
$posts=mysqli_query($connection,$query);
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<section class="search__bar">
|
<section class="search__bar">
|
||||||
<form class="container search__bar-container" action="">
|
<form class="container search__bar-container" action="<?=ROOT_URL?>search.php" method="GET">
|
||||||
<div>
|
<div>
|
||||||
<i class="uil uil-search"></i>
|
<i class="uil uil-search"></i>
|
||||||
<input type="search" name="" placeholder="Search">
|
<input type="search" name="search" placeholder="Search">
|
||||||
<button type="submit" class="btn">Go</button>
|
<button type="submit" name = "submit" class="btn">Go</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@ -16,305 +30,68 @@ include 'partials/header.php'
|
||||||
|
|
||||||
|
|
||||||
<!-- ===================END OF SEARCH================-->
|
<!-- ===================END OF SEARCH================-->
|
||||||
|
<section class="posts <?= $featured ? "" : "section__extra-margin" ?>">
|
||||||
<section class="posts">
|
|
||||||
|
|
||||||
<div class="container posts__container">
|
<div class="container posts__container">
|
||||||
|
<?php while ($post=mysqli_fetch_assoc($posts)) :?>
|
||||||
<article class="post">
|
<article class="post">
|
||||||
<div class="post__thumbnail">
|
<div class="post__thumbnail">
|
||||||
<img src="./images/blog3.jpg" alt="">
|
<img src="./images/<?=$post['thumbnail']?>" >
|
||||||
</div>
|
</div>
|
||||||
<div class="post__info">
|
<div class="post__info">
|
||||||
<a href="" class="category__button">Wild Life</a>
|
<?php
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
//fetch category
|
||||||
|
$category_id=$post['category_id'];
|
||||||
|
$category_query="SELECT * FROM categories WHERE id=$category_id";
|
||||||
|
$category_result=mysqli_query($connection,$category_query);
|
||||||
|
$category=mysqli_fetch_assoc($category_result);
|
||||||
|
|
||||||
|
$author_id=$post['author_id'];
|
||||||
|
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||||
|
$author_result=mysqli_query($connection,$author_query);
|
||||||
|
$author=mysqli_fetch_assoc($author_result);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<a href="category-posts.php?id=<?=$post['category_id']?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<h3 class="post__title"><a href="post.php?id=<?=$post["id"]?>" >
|
||||||
|
<?=$post['title']?>
|
||||||
|
</a></h3>
|
||||||
<p class="post__body">
|
<p class="post__body">
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
<?= substr($post['body'],0,150) ?>...
|
||||||
</p>
|
</p>
|
||||||
<div class="post__author">
|
<div class="post__author">
|
||||||
<div class="post__author-avatar">
|
<div class="post__author-avatar">
|
||||||
<img src="./images/avatar4.jpg" alt="">
|
<img src="./images/<?= $author['avatar'] ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="post__author-info">
|
<div class="post__author-info">
|
||||||
<h5>By: Jone titus</h5>
|
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||||
<small>June 12,2022 - 20:23</small>
|
<small>
|
||||||
|
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
<?php endwhile ?>
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog4.jpg" alt="">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar5.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog5.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar6.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog6.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar7.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog7.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar8.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog8.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar9.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog9.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar10.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog10.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar11.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog11.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar12.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog12.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar13.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog14.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar14.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog15.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar15.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--=====================================================================
|
<!--=====================================================================
|
||||||
==========================END OF THE POSTS===============================
|
==========================END OF THE POSTS===============================
|
||||||
=================================================================== -->
|
=================================================================== -->
|
||||||
<section class="category__buttons">
|
<section class="category__buttons">
|
||||||
<div class="container category__buttons-container">
|
<div class="container category__buttons-container">
|
||||||
<a href="" class="category__button">Wild Life</a>
|
<?php
|
||||||
<a href="" class="category__button">Music</a>
|
$all_categories_query="SELECT * FROM categories ";
|
||||||
<a href="" class="category__button">Movies</a>
|
$all_categories_result=mysqli_query($connection,$all_categories_query);
|
||||||
<a href="" class="category__button">Travel</a>
|
|
||||||
<a href="" class="category__button">Science & Technology</a>
|
?>
|
||||||
<a href="" class="category__button">Food</a>
|
<?php while ( $category=mysqli_fetch_assoc($all_categories_result) ) : ?>
|
||||||
|
<a href="<?=ROOT_URL?>category-posts.php?id=<?=$category['id']?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<?php endwhile?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!--=======================END OF CATEGORY ===================================-->
|
<!--=======================END OF CATEGORY ===================================-->
|
||||||
|
|
|
@ -1,310 +1,97 @@
|
||||||
<?php
|
<?php
|
||||||
include 'partials/header.php'
|
include 'partials/header.php';
|
||||||
|
|
||||||
|
//fetch posts if id is set
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id=filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$query= "SELECT * FROM posts WHERE category_id=$id ORDER BY date_time DESC";
|
||||||
|
$posts=mysqli_query($connection,$query);
|
||||||
|
}else{
|
||||||
|
header('location: ' . ROOT_URL . 'blog.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<header class="category__title">
|
<header class="category__title">
|
||||||
<h2>Category Title</h2>
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$category_query="SELECT * FROM categories WHERE id=$id";
|
||||||
|
$category_result=mysqli_query($connection,$category_query);
|
||||||
|
$category=mysqli_fetch_assoc($category_result);
|
||||||
|
?>
|
||||||
|
<h2><?= $category['title'] ?></h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
<?php if ((mysqli_num_rows($posts)) > 0) : ?>
|
||||||
<section class="posts">
|
<section class="posts">
|
||||||
|
|
||||||
<div class="container posts__container">
|
<div class="container posts__container">
|
||||||
|
<?php while ($post=mysqli_fetch_assoc($posts)) :?>
|
||||||
<article class="post">
|
<article class="post">
|
||||||
<div class="post__thumbnail">
|
<div class="post__thumbnail">
|
||||||
<img src="./images/blog3.jpg" alt="">
|
<img src="./images/<?=$post['thumbnail']?>" >
|
||||||
</div>
|
</div>
|
||||||
<div class="post__info">
|
<div class="post__info">
|
||||||
<a href="" class="category__button">Wild Life</a>
|
<?php
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
|
|
||||||
|
$author_id=$post['author_id'];
|
||||||
|
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||||
|
$author_result=mysqli_query($connection,$author_query);
|
||||||
|
$author=mysqli_fetch_assoc($author_result);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<h3 class="post__title"><a href="post.php?id=<?=$post["id"]?>" >
|
||||||
|
<?=$post['title']?>
|
||||||
|
</a></h3>
|
||||||
<p class="post__body">
|
<p class="post__body">
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
<?= substr($post['body'],0,150) ?>...
|
||||||
</p>
|
</p>
|
||||||
<div class="post__author">
|
<div class="post__author">
|
||||||
<div class="post__author-avatar">
|
<div class="post__author-avatar">
|
||||||
<img src="./images/avatar4.jpg" alt="">
|
<img src="./images/<?= $author['avatar'] ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="post__author-info">
|
<div class="post__author-info">
|
||||||
<h5>By: Jone titus</h5>
|
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||||
<small>June 12,2022 - 20:23</small>
|
<small>
|
||||||
|
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
<?php endwhile ?>
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog4.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar5.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog5.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar6.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog6.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar7.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog7.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar8.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog8.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar9.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog9.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar10.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog10.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar11.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog11.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar12.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog12.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar13.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog14.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar14.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog15.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.html" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar15.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
<?php else : ?>
|
||||||
|
<div class="alert__message error lg">
|
||||||
|
<p>
|
||||||
|
No posts found for this category
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
<!--=====================================================================
|
<!--=====================================================================
|
||||||
==========================END OF THE POSTS===============================
|
==========================END OF THE POSTS===============================
|
||||||
=================================================================== -->
|
=================================================================== -->
|
||||||
<section class="category__buttons">
|
<section class="category__buttons">
|
||||||
<div class="container category__buttons-container">
|
<div class="container category__buttons-container">
|
||||||
<a href="" class="category__button">Wild Life</a>
|
<?php
|
||||||
<a href="" class="category__button">Music</a>
|
$all_categories_query="SELECT * FROM categories ";
|
||||||
<a href="" class="category__button">Movies</a>
|
$all_categories_result=mysqli_query($connection,$all_categories_query);
|
||||||
<a href="" class="category__button">Travel</a>
|
|
||||||
<a href="" class="category__button">Science & Technology</a>
|
?>
|
||||||
<a href="" class="category__button">Food</a>
|
<?php while ( $category=mysqli_fetch_assoc($all_categories_result) ) : ?>
|
||||||
|
<a href="<?=ROOT_URL?>category-posts.php?id=<?=$category['id']?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<?php endwhile?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!--=======================END OF CATEGORY ===================================-->
|
<!--=======================END OF CATEGORY ===================================-->
|
||||||
|
|
|
@ -458,7 +458,9 @@ footer ul a:hover{
|
||||||
display: grid;
|
display: grid;
|
||||||
place-content: center;
|
place-content: center;
|
||||||
}
|
}
|
||||||
|
.post_info{
|
||||||
|
align-items: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*=======================================================================================
|
/*=======================================================================================
|
||||||
|
|
BIN
images/1677834448avatar15.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
images/1677835117avatar7.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
images/1677835502blog102.jpg
Normal file
After Width: | Height: | Size: 102 KiB |
BIN
images/1677835638blog15.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
images/1677835680avatar3.jpg
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
images/1677835859blog20.jpg
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
images/1677835925avatar1.jpg
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
images/1677836026blog13.jpg
Normal file
After Width: | Height: | Size: 137 KiB |
360
index.php
|
@ -1,328 +1,124 @@
|
||||||
<?php
|
<?php
|
||||||
include 'partials/header.php'
|
include 'partials/header.php';
|
||||||
|
|
||||||
|
//featured
|
||||||
|
$featured_query="SELECT * FROM posts WHERE is_featured=1";
|
||||||
|
$featured_result=mysqli_query($connection,$featured_query);
|
||||||
|
$featured=mysqli_fetch_assoc($featured_result);
|
||||||
|
|
||||||
|
//fetch 9post
|
||||||
|
|
||||||
|
|
||||||
|
$query="SELECT * FROM posts ORDER BY date_time DESC LIMIT 9";
|
||||||
|
$posts=mysqli_query($connection,$query);
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php if (mysqli_num_rows($featured_result) == 1 ) : ?>
|
||||||
<section class="featured" >
|
<section class="featured" >
|
||||||
<div class ="container featured__container">
|
<div class ="container featured__container">
|
||||||
<div class="post__thumbnail">
|
<div class="post__thumbnail">
|
||||||
<img src="./images/blog1.jpg">
|
<img src="./images/<?= $featured['thumbnail'] ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="post__info">
|
<div class="post__info">
|
||||||
<a href="category-posts.php" class="category__button">Wild Life</a>
|
<?php
|
||||||
<h2 class="post__info"><a href="post.php">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Aliquid!</a></h2>
|
//fetch category
|
||||||
|
$category_id=$featured['category_id'];
|
||||||
|
$category_query="SELECT * FROM categories WHERE id=$category_id";
|
||||||
|
$category_result=mysqli_query($connection,$category_query);
|
||||||
|
$category=mysqli_fetch_assoc($category_result);
|
||||||
|
|
||||||
|
$author_id=$featured['author_id'];
|
||||||
|
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||||
|
$author_result=mysqli_query($connection,$author_query);
|
||||||
|
$author=mysqli_fetch_assoc($author_result);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<a href="category-posts.php?id=<?= $category_id ?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<h2 class="post__title"><a href="post.php?id=<?=$featured['id']?>"><?=$featured['title']?></a></h2>
|
||||||
<p class="post__body">
|
<p class="post__body">
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. At quidem reiciendis in fuga consequatur eligendi molestiae, magnam assumenda laborum inventore deleniti. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Reprehenderit maxime sapiente dolores iure quae necessitatibus ut perferendis aliquam fugiat cupiditate.
|
<?= substr($featured['body'],0,300) ?>...
|
||||||
</p>
|
</p>
|
||||||
<div class="post__author-avatar">
|
<div class="post__author-avatar">
|
||||||
<img src="./images/avatar3.jpg">
|
<img src="./images/<?= $author['avatar'] ?>">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="post__author-info">
|
<div class="post__author-info">
|
||||||
<h5>By: Underemployed</h5>
|
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||||
<small>June 10, 2022 - 07:23</small>
|
<small>
|
||||||
|
<?=date("M d, Y -H:i" , strtotime($featured['date_time']))?>
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<?php endif ?>
|
||||||
<!-- ===================END OF FEATURED================-->
|
<!-- ===================END OF FEATURED================-->
|
||||||
|
|
||||||
<section class="posts">
|
<section class="posts <?= $featured ? "" : "section__extra-margin" ?>">
|
||||||
|
|
||||||
<div class="container posts__container">
|
<div class="container posts__container">
|
||||||
|
<?php while ($post=mysqli_fetch_assoc($posts)) :?>
|
||||||
<article class="post">
|
<article class="post">
|
||||||
<div class="post__thumbnail">
|
<div class="post__thumbnail">
|
||||||
<img src="./images/blog3.jpg" alt="">
|
<img src="./images/<?=$post['thumbnail']?>" >
|
||||||
</div>
|
</div>
|
||||||
<div class="post__info">
|
<div class="post__info">
|
||||||
<a href="" class="category__button">Wild Life</a>
|
<?php
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
//fetch category
|
||||||
|
$category_id=$post['category_id'];
|
||||||
|
$category_query="SELECT * FROM categories WHERE id=$category_id";
|
||||||
|
$category_result=mysqli_query($connection,$category_query);
|
||||||
|
$category=mysqli_fetch_assoc($category_result);
|
||||||
|
|
||||||
|
$author_id=$post['author_id'];
|
||||||
|
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||||
|
$author_result=mysqli_query($connection,$author_query);
|
||||||
|
$author=mysqli_fetch_assoc($author_result);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<a href="category-posts.php?id=<?=$post['category_id']?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<h3 class="post__title"><a href="post.php?id=<?=$post["id"]?>" >
|
||||||
|
<?=$post['title']?>
|
||||||
|
</a></h3>
|
||||||
<p class="post__body">
|
<p class="post__body">
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
<?= substr($post['body'],0,150) ?>...
|
||||||
</p>
|
</p>
|
||||||
<div class="post__author">
|
<div class="post__author">
|
||||||
<div class="post__author-avatar">
|
<div class="post__author-avatar">
|
||||||
<img src="./images/avatar4.jpg" alt="">
|
<img src="./images/<?= $author['avatar'] ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="post__author-info">
|
<div class="post__author-info">
|
||||||
<h5>By: Jone titus</h5>
|
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||||
<small>June 12,2022 - 20:23</small>
|
<small>
|
||||||
|
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
<?php endwhile ?>
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog4.jpg" alt="">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar5.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog5.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar6.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog6.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar7.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog7.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar8.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog8.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar9.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog9.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar10.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog10.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar11.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog11.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar12.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog12.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar13.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog14.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar14.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="post">
|
|
||||||
<div class="post__thumbnail">
|
|
||||||
<img src="./images/blog15.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__info">
|
|
||||||
<a href="" class="category__button">Wild Life</a>
|
|
||||||
<h3 class="post__title"><a href="post.php" >Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem, iusto!</a></h3>
|
|
||||||
<p class="post__body">
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, exercitationem! Minima ipsam obcaecati commodi nam aliquid delectus magnam molestiae nobis?
|
|
||||||
</p>
|
|
||||||
<div class="post__author">
|
|
||||||
<div class="post__author-avatar">
|
|
||||||
<img src="./images/avatar15.jpg" alt="">
|
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
|
||||||
<h5>By: Jone titus</h5>
|
|
||||||
<small>June 12,2022 - 20:23</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--=====================================================================
|
<!--=====================================================================
|
||||||
==========================END OF THE POSTS===============================
|
==========================END OF THE POSTS===============================
|
||||||
=================================================================== -->
|
=================================================================== -->
|
||||||
<section class="category__buttons">
|
<section class="category__buttons">
|
||||||
<div class="container category__buttons-container">
|
<div class="container category__buttons-container">
|
||||||
<a href="" class="category__button">Wild Life</a>
|
<?php
|
||||||
<a href="" class="category__button">Music</a>
|
$all_categories_query="SELECT * FROM categories ";
|
||||||
<a href="" class="category__button">Movies</a>
|
$all_categories_result=mysqli_query($connection,$all_categories_query);
|
||||||
<a href="" class="category__button">Travel</a>
|
|
||||||
<a href="" class="category__button">Science & Technology</a>
|
?>
|
||||||
<a href="" class="category__button">Food</a>
|
<?php while ( $category=mysqli_fetch_assoc($all_categories_result) ) : ?>
|
||||||
|
<a href="<?=ROOT_URL?>category-posts.php?id=<?=$category['id']?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<?php endwhile?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!--=======================END OF CATEGORY ===================================-->
|
<!--=======================END OF CATEGORY ===================================-->
|
||||||
|
|
|
@ -4,5 +4,5 @@ require 'config/constants.php';
|
||||||
session_destroy();
|
session_destroy();
|
||||||
|
|
||||||
header('location: ' . ROOT_URL);
|
header('location: ' . ROOT_URL);
|
||||||
die;
|
die();
|
||||||
?>
|
?>
|
50
post.php
|
@ -1,5 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
include 'partials/header.php'
|
include 'partials/header.php';
|
||||||
|
|
||||||
|
//fetch 9post
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id=filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$query="SELECT * FROM posts WHERE id=$id";
|
||||||
|
$result=mysqli_query($connection,$query);
|
||||||
|
$post=mysqli_fetch_assoc($result);
|
||||||
|
$author_id=$post['author_id'];
|
||||||
|
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||||
|
$author_result=mysqli_query($connection,$author_query);
|
||||||
|
$author=mysqli_fetch_assoc($author_result);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
header('location: ' . ROOT_URL . 'blog.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,29 +28,24 @@ include 'partials/header.php'
|
||||||
<section class="singlepost">
|
<section class="singlepost">
|
||||||
<div class="container singlepost__container">
|
<div class="container singlepost__container">
|
||||||
|
|
||||||
<h2>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas, dolore.</h2>
|
|
||||||
|
<h2>
|
||||||
|
<?=$post['title']?>
|
||||||
|
</h2>
|
||||||
<div class="post__author">
|
<div class="post__author">
|
||||||
<div class="post__author-avatar">
|
<div class="post__author-avatar">
|
||||||
<img src="./images/avatar4.jpg" alt="">
|
<img src="./images/<?= $author['avatar'] ?>"> </div>
|
||||||
</div>
|
|
||||||
<div class="post__author-info">
|
<div class="post__author-info">
|
||||||
<h5>By: Jone titus</h5>
|
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||||
<small>June 12,2022 - 20:23</small>
|
<small>
|
||||||
|
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="singlepost__thumbnail">
|
<div class="singlepost__thumbnail">
|
||||||
<img src="./images/blog45.jpg" >
|
<img src="./images/<?=$post['thumbnail']?>" >
|
||||||
</div>
|
</div>
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
<p><?=$post['body']?></p>
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo quae numquam exercitationem optio aperiam accusamus, debitis at, sint illo accusantium possimus quo maiores! Aperiam pariatur, eligendi in tempore autem fugit perspiciatis praesentium dolore rerum ipsum molestias atque blanditiis iure labore.</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
86
search.php
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
require 'partials/header.php';
|
||||||
|
|
||||||
|
//if input is there
|
||||||
|
if((isset($_GET['search'])) && isset($_GET['submit'])){
|
||||||
|
$search=filter_var($_GET['search'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
$query="SELECT * FROM posts WHERE title like '%$search%' ORDER BY date_time DESC";
|
||||||
|
$posts=mysqli_query($connection,$query);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
header(("location: " . ROOT_URL . 'blog.php'));
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if((mysqli_num_rows($posts) > 0)) : ?>
|
||||||
|
<section class="posts section__extra-margin">
|
||||||
|
|
||||||
|
<div class="container posts__container">
|
||||||
|
<?php while ($post=mysqli_fetch_assoc($posts)) :?>
|
||||||
|
<article class="post">
|
||||||
|
<div class="post__thumbnail">
|
||||||
|
<img src="./images/<?=$post['thumbnail']?>" >
|
||||||
|
</div>
|
||||||
|
<div class="post__info">
|
||||||
|
<?php
|
||||||
|
//fetch category
|
||||||
|
$category_id=$post['category_id'];
|
||||||
|
$category_query="SELECT * FROM categories WHERE id=$category_id";
|
||||||
|
$category_result=mysqli_query($connection,$category_query);
|
||||||
|
$category=mysqli_fetch_assoc($category_result);
|
||||||
|
|
||||||
|
$author_id=$post['author_id'];
|
||||||
|
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||||
|
$author_result=mysqli_query($connection,$author_query);
|
||||||
|
$author=mysqli_fetch_assoc($author_result);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<a href="category-posts.php?id=<?=$post['category_id']?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<h3 class="post__title"><a href="post.php?id=<?=$post["id"]?>" >
|
||||||
|
<?=$post['title']?>
|
||||||
|
</a></h3>
|
||||||
|
<p class="post__body">
|
||||||
|
<?= substr($post['body'],0,150) ?>...
|
||||||
|
</p>
|
||||||
|
<div class="post__author">
|
||||||
|
<div class="post__author-avatar">
|
||||||
|
<img src="./images/<?= $author['avatar'] ?>">
|
||||||
|
</div>
|
||||||
|
<div class="post__author-info">
|
||||||
|
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||||
|
<small>
|
||||||
|
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
<?php endwhile ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?php else : ?>
|
||||||
|
<div class="alert__message error lg section__extra-margin">
|
||||||
|
<p>No post found for this search</p>
|
||||||
|
</div>
|
||||||
|
<?php endif?>
|
||||||
|
<!--=====================================================================
|
||||||
|
==========================END OF THE POSTS===============================
|
||||||
|
=================================================================== -->
|
||||||
|
<section class="category__buttons">
|
||||||
|
<div class="container category__buttons-container">
|
||||||
|
<?php
|
||||||
|
$all_categories_query="SELECT * FROM categories ";
|
||||||
|
$all_categories_result=mysqli_query($connection,$all_categories_query);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php while ( $category=mysqli_fetch_assoc($all_categories_result) ) : ?>
|
||||||
|
<a href="<?=ROOT_URL?>category-posts.php?id=<?=$category['id']?>" class="category__button"><?=$category['title']?></a>
|
||||||
|
<?php endwhile?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<!--=======================END OF CATEGORY ===================================-->
|
||||||
|
<?php
|
||||||
|
include './partials/footer.php';
|
||||||
|
?>
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require "config/database.php";
|
require "config/database.php";
|
||||||
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
if(isset($_POST['submit'])){
|
if(isset($_POST['submit'])){
|
||||||
// getting input
|
// getting input
|
||||||
|
@ -30,14 +29,15 @@ if(isset($_POST['submit'])){
|
||||||
|
|
||||||
// set session for access control
|
// set session for access control
|
||||||
$_SESSION['user-id'] = $user_record['id'];
|
$_SESSION['user-id'] = $user_record['id'];
|
||||||
|
$_SESSION['signin-success'] = "User successfully logged in";
|
||||||
|
|
||||||
//set session if user is admin
|
//set session if user is admin
|
||||||
if($user_record['is_admin']==1){
|
if($user_record['is_admin']==1){
|
||||||
$_SESSION['user_is_admin'] == true;
|
$_SESSION['user_is_admin'] = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
//log in user
|
//log in user
|
||||||
header('location: ' . ROOT_URL . 'admin/');
|
header('location: ' . ROOT_URL . 'admin/index.php');
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$_SESSION['signin'] = "Please check your input";
|
$_SESSION['signin'] = "Please check your input";
|
||||||
|
|
13
signin.php
|
@ -28,19 +28,20 @@ unset($_SESSION['signin-data']);
|
||||||
|
|
||||||
<div class="container form__section-container">
|
<div class="container form__section-container">
|
||||||
<h2>Sign In</h2>
|
<h2>Sign In</h2>
|
||||||
|
<?php
|
||||||
|
if(isset($_SESSION['signup-success'])):
|
||||||
<?php if(isset($_SESSION['signin-success'])): ?>
|
?>
|
||||||
|
|
||||||
<div class="alert__message success">
|
<div class="alert__message success">
|
||||||
<p>
|
<p>
|
||||||
<?=$_SESSION['signin-success'];
|
<?= $_SESSION['signup-success'];
|
||||||
unset($_SESSION['signin-success']);
|
unset($_SESSION['signup-success']);
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php elseif(isset($_SESSION['signin'])): ?>
|
<?php elseif(isset($_SESSION['signin'])): ?>
|
||||||
|
|
||||||
<div class="alert__message error">
|
<div class="alert__message error">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
|
||||||
include "config/constants.php";
|
include "config/constants.php";
|
||||||
|
|
||||||
//get beck form DATA IF THERE IS A REGISTRATION ERROR
|
//get beck form DATA IF THERE IS A REGISTRATION ERROR
|
||||||
|
@ -9,6 +9,8 @@ $username=$_SESSION['signup-data']['username'] ?? null;
|
||||||
$email=$_SESSION['signup-data']['email'] ?? null;
|
$email=$_SESSION['signup-data']['email'] ?? null;
|
||||||
$createpassword=$_SESSION['signup-data']['createpassword'] ?? null;
|
$createpassword=$_SESSION['signup-data']['createpassword'] ?? null;
|
||||||
$confirmpassword = $_SESSION['signup-data']['confirmpassword'] ?? null;
|
$confirmpassword = $_SESSION['signup-data']['confirmpassword'] ?? null;
|
||||||
|
|
||||||
|
|
||||||
//delete signup data session
|
//delete signup data session
|
||||||
unset($_SESSION['signup-data']);
|
unset($_SESSION['signup-data']);
|
||||||
|
|
||||||
|
|