Between blogs, social networks, customizable homepages.In the recent years, Web sites gained in
features and at the same time it became more and more complex.
That time of the "personal web page" is far! There a time when we could simply create a basic site
A bit of text, some pictures: wp here is Our personal site was ready.
Today it is different: it must move! We expected that a site is regularly updated:
we want to see news on the homepage, we wants to comment, discuss on forums,
Briefly, participate in the life of the site.
The PHP language has been designed precisely to create sites "live" (known as dynamic sites). If
you want you also learn to create websites dynamic, it's your lucky day: you're on
a course for beginners in PHP!
The key is to read the entire chapters in order. Then it goes all alone and you
soon wonder what you are capable of doing!
To use PHP, you must know in advance XHTML and CSS.
What do you mean these languages do you say anything?
You do not even know what a "language"?
It is therefore necessary that you first read my class website design in [URL="http://eurobattle.net/showthread.php?t=101610"]XHTML and CSS[/URL] before coming back here!
what makes the success of the Web today, is both its simplicity and ease of access. An ordinary web surfers did not need to know "how it works behind". And fortunately for him.
if you read my tutoriel of (x)html & css then Congratulations you are officielly an apprentice webmaster but it still not over , above all, you gonna need to know the basics of running a website.
What is a server and a client?
How does one's dynamic site?
What does PHP and MySQL?
This first chapter is here to answer all these questions and show you that you are able to learn to create dynamic websites.
All readers will be reassured to know in the end they start at the same level!
How does the web Work
When you want to visit a website, you type its address in your web browser, either Firefox, Internet Explorer, Opera, Safari or another.
But do you ever wondered how did the web page to reach you?
You should know that the Internet is a network of computers. These can be classified into two categories:
- Customers: These are Internet computers as you. Your computer is therefore part of the class of customers. Each client represents a visitor to a website. In schemes that follow, the computer of a client will be represented by this image:
- The servers : they are powerful computers that store and deliver web sites to users, that is to say to customers. Most Internet users have never seen a server of their lives. However, the servers are essential for the proper functioning of the web.
Note:Most of the time, the server has no screen: it stays on and works alone without human intervention, 24/24, 7 / 7. A true convict labor xD .
We summarize: your computer is called the client, while the computer that owns the website is called the server. How do the two communicate?
It is precisely here that makes the difference between a static and a dynamic site. Let's see together what is changing.
Case of a static site
When the site is static, the pattern is very simple, This happens in two stages:
- The client asks the server to see a web page.
- The server responds by sending the requested page.
the communication is pretty basic:
- "Hello, I am the client, I would like to see this web page."
- "well sure, here's the page you requested me."
On a static site,nothing else happens. The server stores web pages and sends them to customers who request them without change.
For a dynamic site
When the site is dynamic, there is an intermediate step: the page is generated.
The client asks the server to see a web page.
The server prepares page specifically for the customer.
The server sends the page it has generated.
The web page is generated whenever a customer demands it. This is precisely what makes dynamic sites live: the contents of a page can change from one moment to another.
That is how some sites are able to show by example your nickname on all pages. Because the server generates a page each time he requests one, it can be customized to the tastes and preferences of the visitor (and display its nickname among others).
When creating a website, one has to handle not one but several languages. As a webmaster, it is imperative to know them.
Note :Some programs, called WYSIWYG (What You See Is What You Get), can help the novice to create a static web site without knowing programming languages behind ... But to achieve a dynamic site as we wish, u gonna to surpass that.
- For a static site: XHTML and CSS
Many languages have been created to produce websites. Two of them are an essential basis for all webmasters:
XHTML is the language on the basis of websites. It's very similar to HTML but imposes few rules a bit stricter. Whenever possible I recommend using XHTML rather than HTML because it forces you to treat the source code of your site.- For a dynamic site: add PHP and MySQL
Whatever the website that we want to create XHTML and CSS are essential. However, they are not sufficient to make dynamic sites. It must be supplemented with other languages.
It is precisely the whole purpose of this course you will learn to manipulate PHP and MySQL to create a dynamic Web site.
- PHP: it is a language that only servers understand and can make your site dynamic. This is PHP "generates" the web page as we saw on a previous schemes.
This is the first language we discover in this course. It can work alone, but it really does interest if it is combined with a tool such as MySQL. Here is a PHP code:
<?php echo "you are the visitor n°" . $nbre_visitors; ?>- MySQL: this is called a DBMS (Database System Management ). Simply put, its role is to record data in an organized manner to help you find them easily later. Thanks to MySQL that you can save the list of members of your site, posts on the forum, etc.. The language that communicates with the database is called SQL. Here is a code in SQL:
SELECT id, author, message, datemsg FROM goldbook ORDER BY datemsg DESC LIMIT 0, 10
Note: PHP and MySQL are called free software. Among other things, it gives you guarantees of sustainability: everyone can contribute to their development, you may not see all webmasters ignore the PHP and MySQL overnight, and it is very important !
On the other hand, PHP and MySQL are available for free. This means something important: you will not pay a cent to build your website .
PHP can work by itself and sufficient to create a dynamic site, but things get really interesting when combined with a DBMS such as MySQL. However for simplicity, let us forget for the moment about MySQL and let's focus On PHP.
PHP generates XHTML
Customers are unable to understand the PHP code, they know that XHTML and CSS. Only the server can read PHP.
PHP's role is precisely to generate XHTML (you can also generate the CSS, but it's rare), the code is then sent to the client in the same way as a static site:
PHP has decided what will be posted on the web page sent to the visitor
PHP is a programming language used on many servers to make decisions. It decides PHP XHTML code that will be generated and sent to the customer every time.
To understand the appeal of all this, consider an example. Can be written in PHP: "If the visitor is a member of my site and is called Jonathan, Jonathan displays Welcome on the web. But if this is not a member of my site displays Welcome place and the visitor to register. "
And the competition?
XHTML and CSS have no competitors cause they are standards. Everyone is supposed to know how to use them on all websites.
However, in terms of dynamic websites, PHP and MySQL are far from alone on the spot. I can not get a complete list of competitors, it would be too long (and boring!). However, for your general knowledge should at least know a few other big names.
Firstly, if there is a tendency to combine PHP and MySQL to achieve powerful dynamic sites, do not mix the two. The former has different competitors in the second
It is a very basic example of dynamic site: whether you are a registered member or not, you will not see the same things and will perhaps not have access to all sections.
Competitors PHP
Among the competitors of PHP include:
- ASP. NET developed by Microsoft, it operates. NET framework familiar to C # developers (a framework is a set of libraries that provide services to developers). This language can be interesting if you are used to develop in C #. NET and you do not want to be disoriented.
- Ruby on Rails: very active, this framework can be used with the Ruby language and allows for dynamic sites quickly by following certain conventions.
- Django: It is similar to Ruby on Rails, but it is used in Python.
- Java and JSP (Java Server Pages): more commonly called "JEE", it is particularly used in the professional world. It requires a certain rigor. The establishment of a JEE project is traditionally a bit longer and heavier, but the system is popular with professionals and institutions (which is used on the website of French taxes, for example).
Which one in the lot? Which is better?
Given the purpose of this course, you expect me to respond instantly "PHP!". But no. In fact, everything depends on your programming skills. If you've ever used Java, you will quickly feel comfortable with JSP. If you know Python, Django seems entirely appropriate.
As for PHP, it stands out from its competitors by a large community that can help you quickly on the internet if you have any problems. The language is easy to use, ideal for beginners and professionals alike: Wikipedia and Facebook are examples of famous and popular sites that work with PHP.
In short, there is no better choice. I recommend the language for which you are most certain to have someone to help you. The PHP in this sense is often a very good choice.
Competitors MySQL
Regarding databases, the choice is again very broad.
However, while PHP and its competitors are mostly free and open, this is not the case for most DBMS.
Among the competitors of MySQL, I advise you to know (at least in name):
- Oracle DBMS is the most famous, the most complete and most powerful. Unfortunately, it is paying (and expensive), what the reserve rather businesses who already use it heavily. However, there are free versions of Oracle including for those who want to learn to use it.
- Microsoft SQL Server by Microsoft, it is often used in combination with ASP. NET, although it can be used with any other language. It is rewarding, but there are limited free versions.
- PostgreSQL: it is a free and open DBMS such as MySQL, which offers more advanced features. Sometimes compared to Oracle, he remains a long way to go. It has a community a little less important as MySQL and Oracle.
- SQLite: the DBMS the simplest and smallest. It is free but has very few features (which is sometimes enough). Its big advantage is to be very light.
As you can see, you can choose between many tools to achieve a dynamic site. Most of them are free.
Know that you can combine a priori these tools as you see fit. For example, you can easily use PHP with a database other than MySQL, 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 no coincidence that this tutorial deals with these two tools that have proven their values
Again, this list is not exhaustive but presents at least a few big names.
For information, MySQL DBMS is by far the most free and unrestricted use. Among the solutions professional pay, Oracle is the most advanced and most widely used but its use is mainly reserved for large companies.
Ultimately, if your means are limited, you do not have much choice for the DBMS. MySQL is the most appropriate because it is free,powerful and used by many people .
You should now have a good idea about PHP and MySQL. If you remember that
PHP generates XHTML personalized for each visitor and MySQL is used to store data, you already know the principal.
In the first part of this course we will learn PHP smoothly. We therefore put aside
MySQL will not storing data in a first time. Once you have acquired a certain
level in PHP, that's it for today see you all in the 2nd lesson for both windows and ubuntu