Module 10: Inserting Data into MySQL with PHP


For this module, I connected my PHP code to my MySQL database on InfinityFree and used a basic HTML form to insert new records. The goal was to take data submitted from the form and insert it into the table I created in Module 9.

I built a simple form that collects a user’s first and last name and sends it to a file called insert.php. Inside that file, I used PHP’s MySQLi extension to connect to the database. Once connected, I used a basic SQL statement to insert the form data into the users table.
After uploading the files to my InfinityFree htdocs directory, I was able to submit data from the form and see the new record appear instantly inside phpMyAdmin.

The easiest part was creating the form itself, the HTML side is always straightforward. The trickier part was confirming the exact credentials from InfinityFree (server name, username, password, and database name) since each one needs to match exactly. Once the connection worked, everything else ran smoothly.

This assignment tied everything together, building the table in Module 9 and now connecting to it from PHP. It’s a small step toward dynamic web applications, where front-end forms actually feed data into a live database.

Comments

Popular posts from this blog

Module 8: PHP Forms and GET vs POST

Module 2: Introduction to HTML, CSS, and FTP

Working with Datetime and Timedelta in Python