Server side scripting

This page is part of Ron Mertens' web page guides.

If you read the server side vs client side, you know that server side scripting means that the server executes some code, and generates an HTML (plus maybe CSS and javascript) file, for your browser to view.


Languages

There are lot's of server side languages. Most of them are used to the same purpose - to create software (an executable, or script) that runs on the server side, and outputs a HTML page (perhaps with CSS and Javascript, too). Common languages include -

PHP

PHP is probably the most popular language. The main advantage of this language is that it is an 'open-source' language, which means that you'll get it for free in your server. It also runs under linux, so most cheap hosting will include PHP.

PHP is a script language. This means that you do not need to compile it or anything. You can start writing your PHP script using notepad (or obviously work in some better IDE), put the file in the server, point to it using your browser, and your PHP application works!

PHP integrates quickly with HTML, and it basically can be written inside HTML files.

Templates with PHP

One of the useful things you can easily do with PHP is templates. Let's say you are writing some normal static pages. You have several pages, each showing a different content of course. But they do share some common things - maybe the top menu, or the bottom part. Using PHP you can put the common parts in different files, and then simply 'import' them into your HTML file.

It's very simple. You write the following code -

<strong>
<?php
require('myTemplateHTML.php');
?>

And the file myTemplateHTML.php should include the shared HTML code you want to place at that location.

Please note that if you include PHP code inside your html code like that, you must either name your file with the php extension (so that the server will know to execute it via PHP) or tell your server to treat all HTML as PHP files (it works).

Databases

Usually PHP will interact with some database on your server. This will be used to save data (user data, blog entries, forum topics, whatever).

The common platform on Linux machines is MySQL. It's an open source database software, which is very robust.
PHP integrates easily with MySQL, and most likely that your host already has MySQL installed on your server.

What's next?

The next part in our guide is Content Management Systems.