Revise PHP Guestbook + Office Release

This commit is contained in:
Evan G. 2024-04-27 09:45:44 -05:00
parent 1ee016d911
commit c23e9ce05b
1 changed files with 7 additions and 5 deletions

View File

@ -9,14 +9,16 @@ draft: false
comments: true
---
# What is PHP?
PHP is a server-side scripting language. It can be used for a ton of things. The Project I started on stems from building a new [website Redesign](https://fbievan.live/redesign.html) (broken link).
PHP is a server-side scripting language. It can be used for a ton of things. The Project I started on stems from building a new [website Redesign](https://fbievan.live/redesign.html) (broken link). I did not originally plan to finish the guestbook first, but I got interested into PHP, and programming in general. This is one of the few projects that I coded from the bottom up.
# A guestbook
There was a lot of places I went to figure out this, mainly from [w3schools](https://w3schools.com) (**JS WARNING + AD WARNING**), the [PHP Documentation](https://www.php.net/manual/), and [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/). My plan from the beginning was using PHP to store data from a HTML Form, to a JSON File. This implementation could be later extended to use SQL, or other mediums. This is the first part of a guestbook. If you want to see my code, you should be able to see it here [code](link).
There was a lot of places I went to figure out PHP, mainly from [w3schools](https://w3schools.com) (**JS WARNING + AD WARNING**), the [PHP Documentation](https://www.php.net/manual/), and [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/). My plan from the beginning was using PHP to store data from a HTML Form, to a JSON File. This implementation could be later extended to use SQL, or other mediums. This is the first part of a guestbook. If you want to see my code, you should be able to see it here [code](https://git.fbievan.live/fbievan/Website-Redesign/src/branch/main/guestbook).
This has been implemented elsewhere, but I wanted the codebase to be very easy to maintain, so I created my own, so I have a better understanding of PHP. I have always kind of felt that I have always taken, without giving anything back, so I started work on this project, and hope that this can be a learning tool for some people.
This has been implemented elsewhere, but I wanted the codebase to be very easy to maintain, so I created my own. This led to me having a better understanding of PHP. I have always kind of felt that I have always taken, without giving anything back, so I started work on this project, and hope that this can be a learning tool for some people.
## What this actually needed to do.
This [blost](https://alpha.polymaths.social/@amin/statuses/01HW9D7JDTZK4HH6SCB4JAS2DW) is meant to be most of a preliminary to a further article about the complete redesign of this site, however I figure that a PHP development article would be pretty cool, so here it is.
## What this actually needed to do and the Original Structure of the Code
First, I needed to receive a request, this was done with an HTML form with a POST request. This POST was to a php script, which needed to first cleanse the HTML code of any scripting or styling, this i used htmlspecialchars function inside of PHP. I stored all of these in variables.
@ -26,7 +28,7 @@ I then used an "array_unshift" to change the array that was gathered from the JS
## A redesign
Well, I didn't like the structure. At a meeting at my schools coding club (hey guys if you see this). I heard about classes and those structures, and I thought, I can use that in my own code. So when I got home, I redesigned the code to use a class. While at it I also added dates, while there is no way to get the timezone of a user (without some major hacks that I did not want to do), without JavaScript. Which was the whole reason I created this project. So I settled for simply storing the date.
Well, I didn't like the structure. At a meeting at my schools coding club (hey guys if you see this). I heard about classes and those structures, and I thought, I can use that in my own code. So when I got home, I redesigned the code to use a class. This meant that my code was now treating the variables as a variable inside of an object. This allowed for much easier expansion of what I wanted to add on later. While at it I also added dates, while there is no way to get the timezone of a user (without some major hacks that I did not want to do), without JavaScript. Which was the whole reason I created this project. So I settled for simply storing the date.
## RSS Feed
This is a very similar structure to what I used in HTML with PHP, to do this, I simply used a foreach loop which cycled through every object in the JSON array and make an item with the title of the item's user, and then the description being the message. It was fairly simple, but took a little bit extra to work out the kinks with.