fbpx

A modern website is more than just a collection of some HTML pages.

If all you have is some basic information that you want to make available for the world to see, then you can create HTML files and put them in your website directory. You might have other files to put on the server too such as images and cascading style sheets.

You can build a website like this and each time you add a new HTML file, you’ll have to link it into your website by finding an existing HTML file that you can modify to place a hyperlink to your new file. This is a lot of work and as your site gets bigger, the chances are greater that you’ll make a mistake and end up with broken links. These are links that no longer point to a valid file.

If all you have is a few pages, then maybe this is all you need. But there’s two big problems with this type of website beyond just the extra work of trying to keep everything linked together. Both problems come back to the need to be able to offer different content to different visitors. That means the web server needs to be able to send different HTML files to different visitors. How do you do this? There’s nothing in HTML that allows this.

Listen to the full episode or read the full transcript below for more information and how a language like PHP solves this by generating HTML for your website visitors.

Transcript

You can still build a website by connecting a server computer to the Internet with a fixed IP address and then running web server software on that computer. Most of the time, all this is done for you already when you sign up for web site hosting. All you have to do is place some HTML files in the directory provided for you.

Or if you have more control over the server, you might need to do this part yourself and create the directories and configure the web server to start listening for requests. I’ll explain how this works in a future episode. For now, all you need to know is that the web server receives a request for a particular URL and knows where to find the files so it can return whatever was requested.

If all you have is some basic information that you want to make available for the world to see, then you can create HTML files and put them in your website directory. You might have other files to put on the server too such as images and cascading style sheets.

You can build a website like this and each time you add a new HTML file, you’ll have to link it into your website by finding an existing HTML file that you can modify to place a hyperlink to your new file.

This is a lot of work and as your site gets bigger, the chances are greater that you’ll make a mistake and end up with broken links. These are links that no longer point to a valid file.

If all you have is a few pages, then maybe this is all you need. But there’s two big problems with this type of website beyond just the extra work of trying to keep everything linked together.

The first problem is this type of website offers the same content to every visitor. Maybe that’s okay for a restaurant website that just wants to post a menu online. Everybody can see the same menu. But it’s not going to work for an online banking website where each visitor expects to see account information specific to them. Or an online store where visitors want to interact with the store and buy things and expect to see a history of just the items they’ve bought.

Anytime you want to let visitors view custom information, or create an account, or interact with other users, then a fixed set of HTML files will no longer work.

The other problem is more for your convenience. Anytime you want to change or update your website, you don’t want to have to make changes to HTML files directly. And I’m not just talking about the difficulty of keeping everything linked together. You’ll either have to edit the HTML files directly on the server or edit them on your local computer and then upload the new versions to the server. Both options are troublesome and require extra steps unrelated to the change you’re trying to make. It would be much better if you could use your website itself to make changes. And unless you’re building a wiki where everybody has the same ability to make changes, you’re going to want to restrict the ability to make changes to only yourself and maybe a few other people.

Both of these problems come back to the need to be able to offer different content to different visitors. That means the web server needs to be able to send different HTML files to different visitors. How do you do this? There’s nothing in HTML that allows this.

The only real solution is to get help from the web server itself. You’re going to need more than just some HTML files. You need to be able to make decisions based on the identity of the person making a request to determine how to handle that request. You need to be able to do things again and again because some visitors might have one item to display in their order history while other visitors might have hundreds of items.

Making decisions and doing things multiple times sounds a lot like programming. And that’s what you need.

Instead of the web server just handing out files when requested, it needs to be able to run code. Now a web server is already an application and has its own code to run. But the developers who built the web server have no way to know your exact needs. The code you need to run can’t be built into the web server itself. Well, let me be clear, you could if you wanted to build your own web server that knows exactly how to handle your website and is customized in every way to fit your needs. This would be a lot of unnecessary work. It’s better to use a web server that’s already built and that knows nothing about the specific needs of your website but that lets you add your own code.

If you’re using a hosting account, then the web server should already be configured to enable you to include programming in your website. If you need to do this yourself, then there’ll be an optional component you can enable depending on which language you plan to use to write your code.

A popular choice for web server programming is PHP. Instead of requesting HTML files from the web server, your visitors will instead be requesting PHP files. Now, this will probably be setup so that visitors don’t even know they’re requesting PHP files.

You can see this if you visit takeupcode.com. The first thing that happens is you’ll be redirected to use https instead of http and then you’ll also be redirected to www.takeupcode.com. Since you don’t specify an actual file, the web server is setup to return a default file which is a PHP file. But because the web server is also setup to enable PHP processing, then instead of just returning this file like it would just return an HTML file, the server opens the PHP file and actually executes the code inside.

This code is part of WordPress which is a common and easy way to create a website. I’ll go into more detail about this later. For now, the important part is that the web server detects that the requested file is a PHP file and is setup to execute the code inside this file instead of just returning it.

So what does this code do? It does a lot. But the main job is to figure out the identity of the user making the request and then figure out what content should be returned. The PHP code creates HTML content for the user making the request and that’s what gets returned. This is how the HTML can be customized for the visitor. The visitor never sees the content in the PHP file. It’s used to generate HTML.