With HTML, PHP, and MySQL, it’s possible to have a very functional web application, like an E-commerce store or a social media website. It will be a very bland website though without CSS and JavaScript.
The only difference between the previous HTML and PHP website and this one is MySQL, the database. The database is a very important part of dynamic websites. We could store all of the data in a CSV file using PHP, but we’d hit limitations very quickly trying to get the data we want. Storing, getting, updating, and removing data from a CSV file can be very tricky. You might recognize those four words. The acronym CRUD (create, read, update, delete) are different operations on the data. It’s possible to have a simple CRUD application using a CSV file, but anything beyond simple queries requires another tool. Instead of using a CSV as our database, we’ll use a tool called MySQL. This tool lets you create queries to create, read, update, and delete your data. The SQL part stands for Structured Query Language.
This tool can definitely be called a language, but you only need to learn as much as you need to accomplish your goals.
What does an HTML, PHP, and MySQL website look like? It is a lot more functional than a static HTML, CSS, JavaScript website. You could create an HTML form that gets a visitor’s email address and password. When he submits that form to the PHP server, PHP will take the data and save it to the database. Besides a couple other things, this is what you would do to register a user. Then, you could create another form to create a product or blog post, and you would also save data from those forms to the database.
Now, the user can save data to your website, leave the website, come back later, and still access the data. This would not be possible with a static website. You cannot store data without a server-side language like PHP.
How do we get information from the user (like his name, email, and password)? In plain HTML, the only way to get data from the user is with forms.
Forms are the only practical way to get information from the user and send it to the database on your server. Forms are great, but the user experience is not. When the user submits the form, the entire page refreshes. Imagine you’re using your favorite Todo website. You create a new todo, and the entire page refreshes. You delete a todo, and the entire page refreshes. You’re half way down the page, editing a todo and save it. The entire page refreshes.
Imagine you’re using your favorite email client. You create a new email, and the entire page refreshes when you click send. You edit a draft and click save. The entire page refreshes. You delete an email, and the entire page refreshes. You try to mark an email as read, and the entire page refreshes.
Yes, with PHP and MySQL, we have a dynamic website where we can save user’s data, but no one’s going to use it for long.