Tutorial contents

This post shows how to create a MySQL database in cPanel and how to connect to it from a webpage using PHP.

I use a Hosting service, which hosts my website and provides cPanel and MySQL databases. This makes the target server a 'localhost', as DB and PHP are on the same server.

This post is split in four parts:

  1. Creating a MySQL database in cPanel
  2. Creating a HTML form
  3. Inject to DB with PHP
  4. Fetch from DB with PHP

NOTE. I'm no expert in security. This tutorial only scratches the surface of what goes on with using databases, and doesn't provide the best final solutions for production environment.

This tutorial is made for the purposes of "having fun and learning stuff".

Getting started

For the creation of the DB, make also a .txt file (or such) where you can save names and passwords along the way.

Image. Notepad ready to save the info.

Let's get to the first part: getting that database running!