312-Module05_merged.pdf
Document Details
Uploaded by Deleted User
Full Transcript
Module 6: Server-side Web Scripting (part 1) Copyright © 2024 bb-mcc Objectives Describe server-side scripting and its role in web development Discuss the fundamental concepts of frequently used server-side scripting languages Utilize server-side scripting technologies to...
Module 6: Server-side Web Scripting (part 1) Copyright © 2024 bb-mcc Objectives Describe server-side scripting and its role in web development Discuss the fundamental concepts of frequently used server-side scripting languages Utilize server-side scripting technologies to handle GET and POST requests. Integrate basic JavaScript code and PHP code to provide database processing features in a real-world web application. Copyright © 2024 bb-mcc Server-side Web Scripting client-side technologies can enable control of appearance and behavior of a rendered page e.g., layout, animation, event-handling, client-side validation server-side scripts can access data resources: fetch, store, pass data to other tools validate incoming data filter, format, customize perform other forms of data processing and analysis trigger communications and notifications control user sessions manage and control data and content access tailor data for individual users Copyright © 2024 bb-mcc Architecture precreated HTML, CSS, front- end scripts (e.g., JS), server- side scripts (e.g., JS, PHP) + form data and components, media and http request + http query parameters other resources Web Server static resources http response URL encoding GET/POST data HTML Cookies database Web Application HTML, CSS, JavaScript Copyright © 2024 bb-mcc Server-side scripting languages PHP (PHP: Hypertext Preprocessor) Server-side JS (NodeJS) Java Servlets and Java Server Pages (JSP) [part of the Java EE specification] Java EE (Oracle) is now Jakarta EE (Eclipse Foundation) ver 8: last version with the Java trademark Jakarta EE includes Jakarta Servlet, … Server Pages, … Server Faces, … Enterprise Beans, … Expression Language, … RESTful WS, etc. Python Active Server Pages (ASP).NET technically use a supported.NET language (C#, F#, Visual Basic) Ruby Copyright © 2024 bb-mcc HTML forms element enables a user to submit data from the client to the server attribute indicates the URL (typically a relative URL in the website) where the data in the form will be sent and handled (some script) attribute indicates the HTTP method used to send to the server. This is typically either GET or POST. Copyright © 2024 bb-mcc HTML forms Forms usually contain elements based on the type of input (other elements used: , , ) attribute: specifies the appearance and behavior of the element attribute: used by the server to identify the data passed to it button or input element (type=”submit”) sends the form data Form validation (client-side) may be done through HTML5 or JavaScript server-side validation is necessary to ensure integrity Reiteration: data for GET methods are included in the URL as a query string, while data for POST methods are encoded in the HTTP message body. Copyright © 2024 bb-mcc HTML forms Form validation (client-side) may be done through HTML5 or JavaScript server-side validation is necessary to ensure integrity Copyright © 2024 bb-mcc Server-side Web Scripting with PHP Copyright © 2024 bb-mcc PHP: Hypertext Preprocessor PHP (currently ver 8.3.12) delimiter for PHP code: symbols PHP code can be combined with HTML markup variables are prefixed by the $ symbol response header info can be set via the header() function echo outputs text that will be displayed on your browser: HTML tags will be interpreted as markup the dot (.) symbol serves as the concatenation operator superglobals are predefined variables that can be accessed from any scope; data type: associative arrays $_SERVER $_GET $_POST $_FILES $_COOKIE $_SESSION $_REQUEST $ENV Copyright © 2024 bb-mcc PHP GET Copyright © 2024 bb-mcc PHP: Post Request Copyright © 2024 bb-mcc PHP Post Response 2 double-quoted strings allow variable interpolation and escape sequences heredoc strings work like double- quoted strings for multiline text; must start with an identifier prefixed with the