phdr has a lot of good points…
Here are my observation after quickly looking over your HTML and Code.
First stop using inline CSS, use an external CSS file.
Better yet use a Web Templating System that way you don’t really have to worry about sanitizing in PHP other than using prepared statements (in my opinion sometimes that is good enough). Two popular Templating systems are Smarty (That is the one I use) and Twig, both can be both found using a Google Search and both can do sanitizing with ease.
Here’s an example of my blog templates (I have a general template that takes care of the basic HTML/CSS structure):
blog.tpl
{extends file="general_page_template.tpl"}
{block name=title}
{$title|escape}
{/block}
{block name=body}
<div class="main">
{nocache}
<h1>The Daily Blog</h1>
<div id="gallery" class="picture-box" data-total="{$journal|count}" >
{counter start=-1 skip=1 print=false}
<div class="article">
{foreach $journal as $cms}
<h2>{$cms.heading} <span class="subheading">by {$cms.author} on {$cms.date_added}</span></h2>
<a class="myLightBox" href="{$cms.image_path}" title="Picture Gallery" data-picture="{counter}"
data-exif="{if $cms.Model}{$cms.Model} --- {$cms.FocalLength} {$cms.Aperture} {$cms.ISO} {$cms.ExposureTime}{/if}"><img class="box" src="{$cms.thumb_path}" alt="Picture for Journal Entry"></a>
<hr>
<p>{$cms.content|nl2br}</p>
{/foreach}
</div>
</div>
{/nocache}
</div>
{block name="aside"}
{/block}
{/block}
Here’s my blog.php file:
require_once '../private/initialize.php';
use Library\Read\Read;
$display = new Read();
$journal = $display->readBlog(); // Read in My Blog Posts
//echo "<pre>" . print_r($journal, 1) . "</pre>";
if (is_logged_in()) {
header("Location: member_page.php");
exit();
}
if (is_logged_in()) {
$smarty->assign('display_status', true);
}
else {
$smarty->assign('display_status', false);
}
$smarty->assign('holidayMessage', $holiday_message);
$smarty->assign('journal', $journal);
$smarty->assign('calendar', $calendar);
$title = "The Photo Journal";
$smarty->assign("title", $title);
$smarty->display('blog.tpl');
As you can see it splits the PHP and HTML/CSS/Javascript in two. In my opinion a person could do just the templating programing without having to know PHP just as long as the backend php developer told the person doing the templating the variables/arrays being used in php.
However, I was going off topic a little. The main thing I was trying to get at is to keep your PHP and HTML/CSS separated as possible, be it using regular php and HTML/CSS or using a templating system. I think you will find it easier making the blog and even the user registration/login system. I have a member page template (member_page.tpl) that only members (Which is only me for the moment) to add/edit/delete posts that are made. I find it easier to using a templating system, but it can be easily made without one. Without using a templating system, do what phdr recommends keep it on one page with most of the PHP on top and the all of the HTML on bottom with a little PHP sprinkle in for you blogging posts.
To see it in action -> https://www.miniaturephotographer.com/blog.php