Save HTML Form Data to a MySQL Database using PHP

Learn how to create a form in HTML, then save the data from that form to a MySQL database using PHP.

For a more detailed version of the techniques shown in this video, check out the full course here:

Please consider supporting my channel:

Recommended hosting:

In this video you’ll learn how to:
– create a form in HTML using best practices
– create form controls for simple text input
– use multi-line text input using the textarea element
– use select lists, radio buttons and checkboxes
– process the submitted form data using PHP
– validate the form data using filter functions
– avoid an SQL injection attack
– use a prepared statement to insert a new record into a database
– create a database and table using phpMyAdmin
– use an SQL INSERT INTO statement to insert a record

Code shown in the video:

Relevant documentation:

00:00 Introduction
00:15 Create the HTML file
01:09 Simple text input
01:38 Labels
02:34 Textarea
03:19 Styling with CSS
04:19 Lists
05:49 Radio buttons
07:36 Fieldset
08:34 Checkbox
09:28 Create the PHP file
11:47 Get the form data
12:55 Filter the data
15:04 Validate the data
16:00 Create the database
16:12 Create the table
17:08 Connect from PHP
19:50 Write the SQL
20:32 SQL injection attack
21:00 Prepared statement
22:08 Bind values to placeholders
23:42 Insert the data
24:06 Summary

#HTML #PHP #MySQL #forms


Leave a Reply

Your email address will not be published. Required fields are marked *