Learnit Training

1. Introduction

1.1. This course

This Online Course is designed to introduce you to PHP and MySQL. You will be guided through the installation and some examples. After this course, you will have an idea of what PHP is and you will be able to create simple PHP pages. If your interest is aroused, it is certainly worthwhile taking a training course led by an experienced trainer.

1.1.1. Prior knowledge

To follow this Online Course you must be familiar with HTML. It is also good if you know what a server is. Experience with programming is not necessary.

1.1.2. Consistency with other courses

PHP, as we use it here, is very closely related to HTML. You can follow a Learnit Training HTML to get familiar with this. If you want to continue working with PHP, you can follow a PHP basic course or a PHP advanced course at Learnit.

1.1.3. Structure

You can simply go through this course chapter by chapter and do the assignments. It is assumed that you have installed the software as described below and that you have always read the previous chapters. Furthermore, screenshots are frequently used. Due to differences in the operating system and other software packages, they may differ from what you see on your screen. Do not attach too much importance to this!

1.2. What is PHP?

In 1994, Rasmus Lerdorf from IBM developed the scripting language PHP, which then stood for Personal Home Page. Since PHP version 3.0 in 1998, it has stood for PHP Hypertext Preprocessor. This is what it does: preprocess hypertext (HTML). A scripting language is a high-level programming language that is designed for simple software development. This language is particularly suitable for developing dynamic web pages.

1.2.1. Dynamic pages

Web pages are originally simple HTML files that sit on a server waiting for a visitor to request them for viewing. This type of page is also called static. On the other hand, there are dynamic pages. These are web pages that are only generated at the moment that they are requested by a visitor who requests a page from a server. The beauty of this is that the page can change again and again, depending on the time, visitor or a completed web form.

There are various techniques for creating dynamic pages. Currently, common methods are ASP(Active Server Pages) from Microsoft and PHP, which we will discuss here.

1.2.2. PHP and HTML

If you do not know what HTML is, it will be difficult for you to follow the rest of this course and it is recommended that you first follow a Training HTML.

PHP and HTML are actually an inescapable tandem. Practically everything you generate with PHP is HTML; we use PHP to generate an HTML file automatically and on demand. A website visitor surfs to a .php file, the PHP interpreter on the web server goes to work, creates HTML and sends it back to the browser which renders it as if it were a normal HTML page. In chapter 2 we will work with a simple example that will illustrate this.

1.2.3. PHP and MySQL

MySQL is an open source database and, although it can be used with other databases as well, it is usually used as the storage mechanism behind a dynamic web page developed with PHP. The database stores all the information, and PHP ensures that this data can be modified and displayed as a web page. In this course, we will discuss some applications that make use of MySQL.

The interrelationship of HTML, PHP and MySQL can be represented as follows:

Client Server

A client, in this example the web browser Firefox, requests a page from the server. The PHP interpreter sends an SQL(Structured Query Language) query to the MySQL database. The database executes the query and sends the resulting data back to the PHP interpreter, which generates HTML around it. This HTML is then sent to the client. If the above is still a bit of a mystery to you, this is no reason to stop, as it will all be covered in more detail in the following chapters!

1.3. Downloading and Installing

As mentioned before, PHP is only a scripting language, and it is not possible to download or install a scripting language. Therefore, we cannot really talk about "installing PHP", but we can install a so-called interpreter. In this course, we will use PHP to generate dynamic web pages. Therefore, we want to install a web server that can interpret PHP.

We assume that you are using a version of MS Windows as your operating system, although this is not essential for taking this course.

1.3.1. XAMPP

PHP is almost always used in combination with the web server Apache and the database server MySQL. The easiest way to install a working server is to download the XAMPP package. The XAMPP package is particularly suitable for developing and testing on your own computer. In addition to the Apache webserver and the MySQL database server, the package also contains a few frequently used additions. You can download the installer here. For this course, it does not matter which version of XAMPP you are using.

After downloading, open the installer and follow the instructions on the screen.

Note: Remember where you install XAMPP!

After the installation you will be asked if you want to start the "XAMPP control pannel", answer "yes". With the Xampp Control Panel you can start and stop the Apache web server Mysql database. For the course it is important that both are started.


To check whether this went well, go to http://localhost. If all went well, your screen will look something like this:


Should this not be the case, please check first whether you do not already have a server installed (IIS for example) and disable it.

Skype can also be the culprit. It is important to close Skype completely before starting the webser. If it still does not work, you can read the FAQ on the XAMPP website.

There are other packages to choose from besides XAMPP, but in this course we will assume that you have XAMPP installed.