Web pages that use a program running on a server             (web_php.doc)     Oct 25, 2016     Harry Baya

Summary:  

 

 

 

For a better understanding of this area, read the following:

Question:  

Is it possible to create a web-based game such that multiple players, at different locations on the internet, can load the same web page from a server and do the following:  

 

Answer: 

 Yes, but only if a program to support this functionality is running on the server machine.    HTML and JavaScript are run by the browser on the client machine.   Other programming language are used to write programs that run on the server.  

Why is this so?

In order for a player A  to see a move made by player B:

HTML and JavaScript can do this by having a program running on the server that can receive information from one client computer and send it out to other client computers.  

There are a number of computer languages (including Perl, Java, and PHP) that can run on the server and support things like web-based multiplayer games.   Based on my limited experience the best language for beginners to learn and use for this kind of processing is PHP.

Please keep in mind that browsers process HTML and JavaScript code on the client machine.  A web-based multiplayer game requires a program running on the server.  Designers of web-based multiplayer games try to minimize the amount of resources each added player uses on the server machine.    One way to support this goal is to have as much of the game processing done on the client machine, using JavaScript, as possible.

Why PHP? 

Here are my reasons for recommending PHP as the best choice for beginners:

NOTE: .Though the PHP code can be put in the HTML file  being processed by the client browser,  servers and browsers are set up to use the PHP code as a program running on the server.

 

Other things to be aware of:

The program that displays a web page and runs JavaScript code on a personal computer (such as a laptop or desktop machine) is called a browser.   Well known browsers are MS Edge, MS Explorer, Firefox and Google Chrome.   All popular browsers have the restrictions described below.  Using a browser that did not have these restrictions would expose the machine running it to serious risks. 

Web pages require explicit user permission to create or modify files on the machine on which the browser is running.   This restriction is necessary in order to avoid having web pages that could put unwanted programs or data on the browser’s machine.  The ability to let a user permit a web page to create files on his or her machine is used primarily for downloading files from the internet.

A web page that has been read from an internet server requires explicit user permission to read files stored on the machine on which the browser is running.   This restriction is necessary to keep such web pages from reading information from the client machine that should not be shared.    This ability to permit reading files on the client machine is used primarily for uploading files to a server (For example a student can upload a term paper to a web site accessed by the appropriate instructor).

Programs running on a server can read, write, and modify, files stored on the server machine.  The internet permits client browser programs to send information to a program running on a server machine.   The internet also permits client browser programs to receive information sent from a server machine.