i-gave-myself-admin.md

I Gave Myself Admin Access and a Guilt Trip

Welcome back, nobody!

Sunday's supposed to be a day of rest. Apparently nobody told me that, because I spent this one building an entire password-protected admin system instead of, I don't know, resting.

The problem I was trying to solve: every time I wanted to add a book, a movie, or a blog post, I had to go into phpMyAdmin and either fill in a form or hand-write SQL — apostrophes doubled-up, dates typed out manually, the works. Fine the first few times, tedious forever. So today's mission was to build myself a proper little dashboard where I can add, edit, and delete all of it from actual pages on my own site.

Locking the door first

Before any of that, I needed a login. Built a /admin/ area protected by a single shared password — since it's just me using it, no need for full user accounts. The password itself is never stored anywhere as plain text; it goes through PHP's password_hash() once, and every login attempt after that just checks against the hash with password_verify(). Wrapped the whole thing in a PHP session, and built a tiny auth-check.php snippet that any future page can include at the very top to instantly become login-only. Turns out "secret page" is genuinely just one line of code once this exists.

Add, edit, delete — times three

Once the door was locked, I built the actual rooms behind it: a form to add books, one for movies, one for blog posts. Each writes straight into the database with proper validation, so a blank field or an out-of-range rating gets caught before it ever reaches MySQL.

Then came the part I hadn't originally planned for tonight — edit and delete. Books first, fully worked through, then Movies and Posts followed fast since the shape was already proven. Blog posts had one genuine wrinkle: editing a post recalculates its reading time (since that's just word count doing its job) but deliberately leaves the slug alone, so a title tweak later doesn't quietly break a link I'd already shared somewhere.

Delete got a proper "are you sure?" popup before anything actually disappears — small thing, but the kind of small thing you're very glad exists the first time you almost click it by accident.

Screenshot of Admin Dashboard

The bug that wasn't really a bug

Only real hiccup today: two dashboard links had slightly different spacing between them, purely because one paragraph had leftover CSS from back when it used to be the first link on the page. Not a bug so much as digital fossil record — a two-second fix once spotted.

Key Features

  • Password-protected /admin/ area, hashed password, session-based login
  • Reusable one-line auth-check.php include — any page can become login-only instantly
  • Full add / edit / delete for Books, Movies, and Blog Posts
  • Blog post edits recalculate reading time but keep the slug fixed, so links never break
  • Native JS confirmation popup before any delete goes through