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.
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.