>> Thursday, February 7, 2013
Static and Dynamic websitesWe consider that there are 2 types of websites: static sites and dynamic sites.
Static sites are ites that are created with HTML and CSS. They work very well but their contents can not be updated automatically, it is necessary that the owner of the site (the webmaster) modifies the source code to add new features. This is not very practical when you have to update a site several times in the same day! This type of site is increasingly rare today, because as soon as we add an element of interaction (such as a contact form), we no longer speak of a static site but dynamic site.
Dynamic websites are more complex, they use other languages in addition to HTML and CSS, such as PHP and MySQL. The contents of these websites are called "dynamic" because it can change without the intervention of the webmaster! Most of the websites that you visit today are dynamic sites. The only prerequisite to learn how to create this type of site is to already know how to make static sites in HTML and CSS.
The objective of this course is to make you able to make dynamic websites completely by yourself, step by step. In fact, it can provide functionalities much more exciting than static sites. Here are some things you will be able to achieve:
Members area: Your visitors can subscribe to your site and have access to sections reserved for them.
Forum: It is common today to see websites which offer a forum for mutual support and discussions.
Visitor counter: You can easily count the number of visitors who have logged in
on your site, or even know the number of visitors in general!
News: You can automate the writing of news, giving your visitors the ability to compose,comment, etc..
Newsletter: You can send an e-mail to all your members regularly to present the new posts and thus encourage them to return to your site.
Of course, these are only some examples. It is possible to go even further, depending on your needs. know for instance that almost all social network sites are dynamic.
But ... Do not get carried away. Before we get there, you have to read and have a lot to learn!
Start with the basics: do you know what happens when you visit a web page?
How does a website functionWhen you want to visit a website, you type its address in your web browser, either Mozilla Firefox, Internet Explorer, Opera, Safari or other. But have you ever wondered how the web page get to you?
You should know that the Internet is a network of computers. These can be classified into two categories:
Clients: computers are Internet users like you. Your computer is therefore part of the category of clients. Each client is a visitor to a website.
Servers: are powerful computers that store and deliver web sites to users, that is to say the customers. Most Internet users have never seen a server in their livea. However, the servers are essential for the proper functioning of the web.
Most of the time, the server has no screen: it stays on and works alone without human intervention,24h/24, 7/7. A real slave labor.
We summarize: your computer is called the client, while the computer that holds the web site is called the server. how both communicate?
It is precisely here that there is a difference between a static website and a dynamic website. Let's see together what they are.\
A static website
1. The client asks the server to view a web page.
2. The server responds by sending the requested page.
Communication is basic:
"Hello, I am the client, I would like to see this web page."
"Look, here's the page you requested me."
On a static site, nothing happens. The server stores the web pages and sends them to clients who request them without change.
A dynamic website
1. The client asks the server to view a web page.
2. The server prepares the page specifically for the client.
3. The server sends the page that is generated.
The web page is generated whenever a client requests it. This is precisely what makes dynamic websites alive: the content of a page may change from one moment to another.
This is how some sites are able to display, for example your nickname on all pages. given the server generates a page every time you ask him for one, he can customize to suit the tastes and visitor's preferences (and display his nickname among others).
Web languagesWhen creating a website, it is necessary to handle not one but several languages. As a webmaster, it is imperative to know.
Some programs, called WYSIWYG (What You See Is What You Get) allow novices to
create static websites without knowing any programming languages behind ... But to achieve a dynamic site as we wish, we will definitely need to get involved in the programming sides.
For a static website
1. HTML is the basic language for websites.
<p>Hello. This is my new website!</p>
2. CSS is the language for formatting websites. While HTML allows you to write the content of your webpages and the structure, the CSS takes care of the formatting and layout. CSS is what we choose including color, size, menus and many other things. Here is an example of CSS code:
font-weight: bold ;
These languages are the basis of all websites. When the server sends the web page to the client, it actually sends the code back in HTML and CSS.
The problem is that when we only know HTML and CSS, we can only produce static sites ... and not Dynamic sites! For the latter, it is necessary to handle other languages in addition to HTML and CSS.
The question we must ask is: do i know HTML and CSS?
If so, this is perfect, you can continue because we will need it later. If the answer is no, do not panic. these languages are not very difficult, they are within the reach of all. You can learn by reading our course on HTML and CSS.
Know that learning these languages is a matter of a few weeks, or even less if you have enough free time.
For a dynamic website we add PHP and MySQL
PHP: is a language that only servers understand and can make your site dynamic. This is PHP "generates" the web page as seen on a previous schemes.
This will be the first language we'll discover in this course. It can work alone, but it is really interesting when combined with tool such as MySQL. Here is a PHP code:
<?php echo "You are visitor n°" . $num_visitors; ?>
MySQL: this is called a DBMS (Database Management System). Its role is
to store data in an organized manner to help you find them easily later. It is thanks to MySQL you can save the list of members of your site, posts on the forum, etc.. the
language to communicate with the database called SQL. Here is a code in SQL:
SELECT id , author, message, datemsg FROM list ORDER BY
datemsg DESC LIMIT 0, 10
PHP and MySQL are freewares. Among other things, it guarantees sustainability: everyone can contribute to its development, you may not see all webmasters ignore the PHP and MySQL overnight, and this is very important! On the other hand, PHP and MySQL are available. This means one essential thing: you do not have to pay a dime to build your website.
PHP can be used alone and is sufficient to create a dynamic site, but things get really interesting when it is combine with a DBMS such as MySQL. However, for simplicity, for the moment forget MySQL and lets focus on PHP.
The role of PHP is precisely to generate HTML (You can also generate the CSS, but it's rare), code is sent to the client in the same way of that of a static website:
PHP is a programming language used on many servers to make decisions. PHP is who decides the HTML code that will be generated and sent to the client each time.
To understand the value of this, consider an example. You can write in PHP: "If the visitor is a member of my site and his name is Jane, display 'Welcome Jane' to the web page. However, if it is not a member of my site show 'Welcome to the site' and offer the visitor to 'register'. This is a very basic example of dynamic site: whether you are a registered member or not, you will not see the same things and may not have access to all sections.
Rivals of PHP and MySQLHTML and CSS are not rivals because they are standards. Everyone is supposed to know them and use them on all websites.
In contrast to what is dynamic websites, PHP and MySQL are far from being alone. We cannot make a complete list of their rivals, it would be too long (and boring!). However, for your general culture you should at least know a few other big names.
Firstly, if there is a tendency to combine PHP and MySQL to make powerful dynamic sites, we should not mix the two. PHP has different rivals compared to MySQL.
Rivals of PHP
ASP.NET: designed by Microsoft, it uses the .NET framework familiar to C# developers (a framework is a set of libraries that provide services for developers). This language can be interesting if you have the habit of developing in C#. NET and you do not want not be disoriented.
Ruby on Rails: active, this framework can be used with the Ruby language and allows to create dynamic sites very fast by following certain conventions.
Django: it is similar to Ruby on Rails, but it uses the Python language.
Java and JSP (Java Server Pages) more commonly called "JEE". It is particularly used in the world of professionals. It requires a certain rigor. Implementation of a project JEE is traditionally a little more longer and heavier but the system is appreciated by professionals and institutions (this is what is used on the Site of taxes, for example).
We can not present all the rivals, but this should already give you a good notion. For information, it is also possible to use eg C or C++, although it is more complex and not necessarily always adapted (clear, We do not recommend it at all).
Which one is better?
Given the purpose of this course, you expect me to answer that "PHP" instantly . But no. In fact, all depends on your programming skills. If you already know Java , you'll soon feel comfortable with JSP. If you know Python, Django seems entirely appropriate.
As for PHP, it distinguishes itself from its competitors by a large community that can help you quickly on the internet if you have problems. This is an easy language to use, ideal for beginners and professionals alike:
Wikipedia and Facebook are examples of famous landmarks that work with PHP.
In short, there is no better choice. We recommend the language in which you are most certain to get helped with. PHP in this sense is often a very good choice.
Rivals of MySQL
However, while PHP and its competitors are mostly free and open source, this is not the case for most DBMS.
Among the competitors MySQL, I advise you to know (at least in name):
Oracle DBMS is the most famous, the most complete and the most powerful. Unfortunately it is not free (and expensive), It is used heavily by large companies. However, there are free versions of Oracle especially for those who want to learn how to use it.
Microsoft SQL Server: published by Microsoft, and is often used in
combination with ASP.NET, although it can be used with any other language. It is not free, but there are limited free versions.
PostgreSQL: it is free and a DBMS such as MySQL, which offers more advanced features. Sometimes compared to Oracle, it remains some way to go. It has a community a little less important as MySQL and Oracle.
SQLite: DBMS is the simplest and smallest. It is free and open source but has very little functionality. Its advantage is being lightweight.
Again, this list is far from complete but presents at least a few big names.
Ultimately, if your resources are limited, you do not have many choices for the DBMS. MySQL is the most appropriate because it is free, effective and used by many people who are likely to help you.
Combinations are possible
of them are free.
Note that you can combine these tools as you see fit. For example, one can easily use PHP with another database, such as Oracle or PostgreSQL. Similarly, MySQL can be used with any other language: Java, Python, Ruby, etc..
However, the combination "PHP + MySQL" is probably the most common. It is not by chance that this course addresses these two tools that have proven their worth.
You should now have a good idea of what PHP and MySQL allow us to do. If you can remember that PHP generates personalized HTML for each visitor and that MySQL store data, you already know the principal.
In the first part of this course we will discover PHP smoothly. We therefore put MySQL aside and will not be storing data in a first time. Once you have acquired a certain level in PHP, we will talk about MySQL and then we can start making very interesting features for your future site.
Read this tutorial in french