1 / 26

Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University

Learn how PHP and JavaScript can be used to create dynamic webpages and web applications. Understand the basics of how the web works and how these scripting languages interact with the client and server. Explore the features of PHP and JavaScript and how they can be used to create interactive web content.

lwolcott
Download Presentation

Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University

  2. 1) PHP – Personal Home Page Scripting Language 2) JavaScript

  3. The transition from static webpages to dynamic webpages means moving from plain webpages to web applications.

  4. In a pill, how the web works? • There are two entities: a client (browser) and a server. • Traditionally, the client sends some information to the server at a specific URL, requesting a response in a form of an HTML file. • The server receives the request, processes it, and sends the HTML file back to the client. • The client receives the file and based on its HTML contents renders the webpage and displays it.

  5. What happens when the request to the server is for execution of a CGI application? • There are two entities: a client (browser) and a server (with a CGI application). • The client sends a request for execution to the server at a specific URL, requesting a response as usual in a form of an HTML file. • The server receives the request, processes it by running a CGI application (a script, a C/C++ program, etc.), whose result is an HTML text, and sends the HTML text back to the client. • The client receives the response and based on its HTML content renders & displays the webpage.

  6. PHP helps doing the same thing as a CGI: • There are two entities: a client (browser) and a server (with a PHP processor engine). • The client sends a request for execution to the server at a specific URL, requesting a response as usual in a form of an HTML file. • The server receives the request, passes it to the PHP engine, which runs a corresponding script and delivers the results as an HTML text to the server, which in turn passes it back to the client. • The client receives the response and based on its HTML content renders & displays the webpage.

  7. PHP Hypertext Preprocessor (Personal Home Pages) A scripting language that offers unified approach to designing dynamic webpages: • it is free (open source) • it is fast in execution and easy to learn • it is universally portable to multiple platforms.

  8. PHP code is embedded in the HTML code. A special tag, usually “<?PHP”: <?PHP /* PHP code goes here */ ?> is recognized as marking the beginning of PHP code. • Symbols “/*” and “*/” are C-style comments • Symbols “?>” mark end of PHP tag

  9. PHP is nearly a typeless language: • data types of variables are not declared beforehand, but determined when a variable is assigned a value • data type of a variable can change when variable receives a different value • integer, double, string, array, object, boolean are the data types used

  10. Variable’s name in PHP must start with a dollar sign $, for example: $var Expression is a valid combination of variables and operators, for example: $var = 13 + ++$var Instruction (more correctly, a statement) is any syntactically valid entity ending with a semicolon, for example: $var = 13 + ++$var;

  11. PHP code can be embedded in HTML directly, for example: <H2>This is <?php echo date('l, F dS Y.'); ?> </H2>

  12. PHP code stored in a file can be also invoked from HTML, for example: <FORM ACTION="welcome1.php" method="post"> <LABEL>First Name: <INPUT TYPE="text" name="firstname" /> </LABEL><BR /> <LABEL>Last Name: <INPUT TYPE="text" name="lastname" /> </LABEL><BR /> <INPUT TYPE="submit"VALUE="GO" /> </FORM>

  13. PHP file welcome1.php would include the code to receive values from the form: <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; echo "Welcome to my website, $firstname $lastname!"; ?>

  14. The typical use of PHP is with a database: • connecting to a database • performing queries • processing the results of a query • updating database entries • logging out and exiting

  15. 1) PHP – Personal Home Page Scripting Language 2) JavaScript

  16. While PHP scripts allow interaction, they execute at the server site, which creates network traffic, so the need exists for running scripts on the client (browser) site. Thus JavaScript was created!

  17. JavaScript has typical syntax of high-level languages, but does not require type declaration for variables. Their data types are determined automatically when a variable is assigned value.

  18. JavaScript allows control of: • the content of webpages • the browser itself, and • the HTML forms on the page.

  19. In a pill, how it all works in JavaScript? JavaScript code is embedded in the HTML code: <SCRIPT LANGUAGE="JavaScript"> ...JavaScript code goes here... </SCRIPT>

  20. The most interesting feature of Javascript is event handling, which is an asychronous program control. Normally a program executes statements sequentially, one after another, perhaps branching, but still in a predetermined sequence.

  21. This sequence may change abruptly when a certain event occurs, which needs immediate attention. Such situations happen with interrupts at the hardware level, and with JAVA and C++ exceptions at the software (programming language) level. To deal with it, one needs to develop an interrupt of exception handler.

  22. In JavaScript, these abrupt events are some action requests triggered by the client. One can program a response to such events using event handlers, that is, code segments that react appropriately, depending on the kind of action desired by the client.

  23. Sample events handled in JavaScript: • onClick • onMouseOver • onKeyDown • onLoad • onSelect • onAbort • and many others.

  24. Handling a sample event via a form (under the assumption that the event handler has been defined separately): <FORM> <INPUT TYPE = ”button” VALUE = ”Click here” onClick=”alert(You clicked on me!” </FORM>

More Related