Kent 0

from what I searched on the internet, I know:

html is basically the content of a webpage. css is used to style the presentation of the content. php is a server-side language to add in user interactivity. javascript is a client-side language to add in user interactivity. (correct me if I am wrong)

but I am not sure which language is executed first. is there a process flow?

and, did I left out any element(language) of a webpage?

many thanks!

1 answer

Ktash 1851
1
point

So, the process flow of a website is very close to what you have. I'll run you through an example website access so you can understand it.

A Page Request

The user requests a page from a web server. The web server, receives the request, and prepares to send the requested page to the user. If the server is setup to do so, it will run a server side language parser and execute the page so that it knows how to process and serve the page correctly (PHP is a common example, as is PERL and ASPX). That code is executed and will often times output a page to send to the user (you can also do this for documents, and other things as well, but we're talking about a page here.

Now, after the code has been run on the server, what is left is a final copy of the page to be served to the user who requested the page. This page will contain no PHP or any other server type language and will instead be in HTML, CSS, and JavaScript (or, often, a subset, but we'll get to that). This page is then sent across the internet to the user, where a web browser processes the page.

A web browser will run the page from top to bottom, and process as it goes along. The webpage is often broken into 3 different syntax pieces that the browser understands and process. Those are HTML, CSS, and JavaScript. HTML is the content of the page, or the data. It will be the words on the page, the order of the content, and the information that is to be consumed (images and video also fall into this category, but that is done using a different language). CSS is how that information looks. It is the look and feel of the page, the colors, the placement of the elements relative to each other, and things like background images. JavaScript is how the user will interact with the page. This will handle the rewriting of information, and sometimes look, based on user actions. This can be things like having a button change something on the page, or reloading certain pieces of the page.

Languages and Their Uses

Now, HTML, CSS, and JavaScript are the most common user consumed languages. Others include things like Flash and Silverlight. Server side languages are languages that the user never really sees or interacts with directly. There are many, many server side languages, and a couple of the most common are PHP, ASP.Net (or ASPX), and Perl / Mason. These usually contain the logic for how to display a page when it needs to be changed for specific users, or when it is something that you want to minimize coding. For example, if every web page you make for a particular site has the same header, and name, you don't want to have to rewrite that 100 times, nor do you want to have to change it 100 when it needs changed. HTML does not support common programming syntax like loops or constructs, and is infact merely data. This is where the server side languages to come in to make it so you can present the same data again and again without having to type it over and over.

There are also a lot of other web technologies that exist besides the ones explained here. For example, many servers often contain databases to store data on the server (like users, news articles, etc) for presenting different information at different times. If you are interested in learning these things, I would recommend doing some personal research, maybe going through some tutorials (the ones at W3 Schools are good), and possibly signing up for some classes maybe at a local college. Personally, I learn by doing, so for me, the best way to learn was to just start playing around with things and seeing what worked and what didn't. And this place, as well as sister sites like StackOverflow are a great place to ask questions and learn.

Hope this helps. Stick around, and if you have any other questions, feel free to post them. Good luck =)

UPDATE: A User's Interaction with the Database

So, a user can interact with a database in a lot of ways. The first, is simply by hitting a page. A lot of servers track page visits, and user statistics by recording certain information about users when the request a page. By this I mean that when a user requests a page, they have to send a lot of other information to the server other than just the page name. The internet is a big place, so they have to send information about whom the server should respond to, what browser they are using (though this can be spoofed), and a lot of other information. Now, one of the other ways the user can interact with a database is with all of this information that gets sent. On a web page, a user can fill out forms (like the ones here) and choose to send that extra information to the server along with their request for a page. This information is then what is used to add comments, update information, or answer questions.

In the server side language, there is a way to extract this extra information out, and to process it. Now, there is also a recent trend among websites to skip having the entire page reload, and instead using JavaScript (dubbed AJAX) to send all this information to the server. Basically, via JavaScript, a page 'load' is initiated without ever leaving the current one. This can be used to hide all this information from the user and make things smoother. So, when you submit a form on a website, it sends all the data along, and then the server side language processes it, and then serves the page that you requested.

Answered almost 6 years ago by Ktash
  • from what you said, I understand php interacts with the database to serve a page. it is very clear for one-way process (when a page is requested), but it is unclear how user can change the database (like adding this comment) since php is no longer running after the page is served.. Kent almost 6 years ago
  • There you go. Updated it with a new section. :) Ktash almost 6 years ago