Module 8: PHP Forms and GET vs POST
Link to my site: http://drew-williams.infinityfree.me/Module8.html
For this module, I created an HTML form that collects a user’s first name, last name, and email address. When the form is submitted, it sends the data to a PHP file on the server, which then displays the submitted information back on the page. I used the POST method for this form because it’s more secure and better suited for sending user input that shouldn’t be visible in the URL.
I also reviewed the difference between $_GET and $_POST in PHP:
- $_GET sends data through the URL. You’ll see the variables appear in the query string, like ?fname=Drew&lname=Williams. It’s fine for search queries or simple data you don’t mind being visible.
- $_POST sends the data in the body of the HTTP request, so it doesn’t appear in the URL. This makes it better for things like login forms or sensitive data.
In my project, the PHP handler uses $_POST to grab each value, then displays it using htmlspecialchars() to sanitize the output. It’s a small but real-world example of how frontend and backend logic connect, the form captures input, and the PHP script processes and responds to it.
The assignment itself was pretty straightforward. Since I already work with APIs and backend systems, the flow of capturing and echoing POST data felt familiar. The main difference is that PHP handles it all server-side without needing a separate API endpoint. Overall, this was a nice, simple exercise in connecting client input with backend processing.
Comments
Post a Comment