Let’s get started

By December 8, 2019 No Comments

So let’s get going. In the above I explained briefly what PHP is, and how you can interact with an SQL database. Now we need PHP for a few things, which I will all touch on in the following order:

  1. Store data into a database
  2. Dynamically load data into a page
  3. Upload files to the server
  4. Alter folders and files on the server
  5. Create an environment for logged-in users

For all these things I will give you short examples of code and explain exactly what they do. My goal is to give you a few pieces of code from which alone you could start building a CMS or some other application. This undertaking doesn’t require a lot of programming skills, but you can ofcourse expand upon it as much as you want.

To start off and make it as structured as possible I first want you to create an empty .php file. We are going to use Object Oriented Programming to connect to our database. This means we will create an object. When loading a regular page, we call a function that creates this object. When this object is created, we can call all kinds of functions that are associated with this object. Inside this object we also establish a connection so that we don’t have to reestablish it everytime we want to interact with the database. I hope it will become clear once we continue.

The base of the .php file should look like this:

class CMS {
protected $host;
protected $username;
protected $password;
protected $table;
var $connection;
public function __construct($HostName, $UserName, $Password, $DbName){
$this->host = $HostName;
$this->username = $UserName;
$this->password = $Password;
$this->table = $DbName;
public function connect() {
$this->connection = mysqli_connect($this->host,$this->username,$this->password,$this->table) or die("Could not connect. " . mysqli_error());


Author admin

More posts by admin

Leave a Reply