Dynamic Web Sites

So far in this class, we've dealt with static websites: when the user requests a page, they just dowload the HTML file from the webserver. The file on the server is exactly the same as what the user would see if they selected "View source code" in their browser.

But if you had a website that had lots of data that was continually updated, it would be very impractical for someone to write static webpage every time it needed to be updated. Google, for instance, doesn't have someone hand coding the HTML of your results page every time you do a web search... instead, they have programs and databases write the HTML for them. This is called a dynamic web page.

The HU 2650 course directory is a dynamic page, which means that I didn't actually write the HTML source code for it. Instead, I wrote a small program using PHP to write the HTML for me.

Every time someone loads the directory page, the server executes a small program inside the file directory.php. This program connects with a MySQL database holding the first name and userid of everyone in the class, and it uses this data to fill in the table of links.

The HTML source code for the directory page—which you can see here— looks very different from the PHP source code sitting on the server (directory.php). This is because the PHP code gets replaced by the HTML before it gets to your browser.