LIS 4365 Web Design Technologies: MySQL and Connection to PHP

This week I took my website building skills from making pretty documents, into being able to make a useful web app. To demonstrate that I had successfully connected my PHP script to a database, I created a simple web app that has a user enter a key and a small message. This is saved on the server and can be accessed again later by entering the same key again. You can try it out here, or follow the link at the bottom of this post.

Creating the table itself seemed to be fairly easy. After I created the database through cPanel, I was able to login to the database through phpMyAdmin. From there it was easy to create the table. The hardest part was deciding on what fields I wanted to use in the table. For the table I created I had two fields, a key for the user to access a specific record. Then each record also had another field that holds a small text string.

Once I had the database set up I had to do quite a bit of PHP coding before I could test it. This made me nervous because I would not know if I was programming it right until I uploaded the code to the server. The hardest part to program were the SQL queries. While I have done a lot of programming and I have learned half a dozen programming languages at this point, I am unfamiliar with SQL’s syntax and grammar structures. One of the issues I had was caused by quoting the wrong things or using the wrong quotes. For most of the queries, I had to look up how to write them. I really enjoy picking up new programming languages and learning the intricacies of their grammar and syntax, I will have SQL under my belt soon.

On the other hand I did enjoy making my PHP code more abstract by pushing code into separate files. For example, To connect to the database, I wrote a function to connect to the database so that I could reuse the code where I needed to and make it easier to maintain.

Overall the code is messy and still needs some work to make the web app have a better user experience, improve reliability and security. At this point I just wanted to demonstrate that I could connect PHP code to SQL. Going further will only send me down rabbit holes I will not be able to escape from.

Links

Module 9 SQL Web App: http://simon-liles.epizy.com/Module9Login.php