Movies and Books Collection

The Project: I wanted to create an online database where my family could view our movie and book collection at a glance. Users should have the ability to view, sort, search the collections. They should also be able to add, edit, and delete entries. It should be secure with user logins so no one else outside our family can make changes.


This project spawned from my interest in learning better PHP. I had only messed around in a few PHP files in WordPress to tweak things here and there. But I knew that to become a real developer someday – and build my own plugins – I would need to have a much deeper understanding of the language.

I bought a book called The Joy of PHP by Alan Forbes. I liked the book because the author’s approach was about building a project using PHP. In it, he leads readers through building a used car website – essentially a web application for salespeople.

He provides the complete files for download on his website so you can follow along. However, I didn’t use much of those files except as a loose reference. I decided to build my own project, using his used car sales app as a guide. I wanted to build a movie database web app for my family to use.

Of course, this made it much more difficult to debug code as I went through the book. I had to take my time, comparing what I wanted to do in my movie database with what he was explaining in his tutorial. A few times, I even emailed Alan to ask him a question and amazingly, he responded fairly quickly. He didn’t just give me the answer, but instead, he asked me questions and helped me figure it out myself. It took days to unravel some issues and find the bugs in my code. In the end, it helped me understand what was going on – on a much deeper level than I would have if I had just been handed the solution.

Problems I had to solve

Initially, I built the site on my local machine. At the time I used MAMP for local development, so it wasn’t hard to get things set up.

My first issue was that some of the PHP code in the book was deprecated. Logging in users securely just didn’t work. I had to do a lot of Googling and digging through Stack Overflow topics before I found a few solutions that might work for my particular project. I tried them all. Finally, I connected successfully to the database, could make edits, add movies, and navigate.

I added comments to remind myself about the old code later.

Then I registered a domain name and moved the whole kit and caboodle online. Moving the files was easy, and importing the MySQL database was a snap.

Except that logging in no longer worked.

After pressing my nose against VS Code for hours, I found the problem. It was a misplaced semicolon – something that I must have nudged when closing files. The frustrating thing was that it wasn’t throwing an error but it prevented the code from working correctly.

A Work in Progress

While the site is up, I still have work to do to make it work as well as I’d like. For one thing, the site is not very secure. While the passwords are MD5 encrypted and I use escape strings, I should really be using PDO to connect to the database.

I also haven’t added the books section yet. It would also be nice to have better sorting views.

I’ll keep hacking at this when I can. In the meantime, you can view the files on my GitHub page. If you have any ideas on how to improve it, please let me know in the comments below, or get in touch.

FIN

Did you enjoy this post? Subscribe privately in your favorite RSS reader!

Right-click the icon to copy the link to my feed.

RSS logo

Or, sign up below to get updates and exclusive content sent to your inbox:

Oh hi there 👋 It’s nice to meet you.

Sign up to receive new content in your inbox, at least every month. Maybe a couple of times.

I don’t spam! I’m vegan.


Posted

by

Comments

One response to “Movies and Books Collection”

  1. […] weird about my struggle there is that I previously coded a whole site from scratch that accomplished that very thing. So why couldn’t I do it in WordPress? I sought some advice […]

Leave a Reply

Your email address will not be published. Required fields are marked *