Some HTTP Examples. A utility which shows all data from incoming requests is here: It is.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

Mission HTML The Search for the Personal Web Page.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 3 PHP (2) : Functions, User Defined Functions & Environment Variables.
XML eXtensible Markup Language. HTML is not extensible One defect of HTML is that it is not extensible In HTML we cannot, for example, define notions.
Common Gateway Interface (CGI). CGI is a protocol: CGI is not a programming language CGI is a protocol for the exchange of information between between.
XML eXtensible Markup Language. HTML is not extensible One defect of HTML is that it is not extensible In HTML we cannot, for example, define notions.
A simple PHP application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the application returns.
15-Jun-15 Ajax with XML. Displaying theAjax response Here is the previous code for dealing with a non-XML response: function alertContents(http_request)
16-Jun-15 HTTP Hypertext Transfer Protocol. 2 HTTP messages HTTP is the language that web clients and web servers use to talk to each other HTTP is largely.
HTML Form Processing Learning Web Design – Chapter 9, pp Squirrel Book – Chapter 11, pp
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
How the web works: HTTP and CGI explained
Lecture 17. Side remark: for-each equivalence again Second-hand cars Item Model Engine Size Price
Python and Web Programming
Definitions, Definitions, Definitions Lead to Understanding.
1 CGI The Common Gateway Interface E-Commerce Prof. Sheizaf Rafaeli.
Creating your website Using Plain HTML. What is HTML? ► Web pages are authored in HyperText Markup Language (HTML) ► Plain text is marked up with tags,
Simple PHP application. A simple application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
ITM352 Javascript and Dynamic Web Pages: Client Side Processing.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
Lecture Note 3: ASP Syntax.  ASP Syntax  ASP Syntax ASP Code is Browser-Independent. You cannot view the ASP source code by selecting "View source"
Web Technologies Computer Security Lecture 9 Tom Chothia.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
A Closer Look at HTTP HyperText Transfer Protocol.
PHP By Jonathan Foss.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
HOW WEB SERVER WORKS? By- PUSHPENDU MONDAL RAJAT CHAUHAN RAHUL YADAV RANJIT MEENA RAHUL TYAGI.
HTML Internet Basics & Beyond. What The Heck Is HTML? HTML is the language of web pages. In order to truly understand HTML, you need to know a little.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Lecture 17. Side remark: for-each equivalence again Second-hand cars Item Model Engine Size Price
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
More on Variables Some related techniques. Header() function void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) header()
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
HTML Links HTML uses a hyperlink to another document on the Web.
 A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests.
 A PHP script can be placed anywhere in the document.  A PHP script starts with  The default file extension for PHP files is ".php".  A PHP file normally.
Getting Started with HTML. HTML  Hyper Text Markup Language  HTML isn’t a program language, its known as a markup language  A Markup language has tags.
1 CS428 Web Engineering Lecture 22 Building Dynamic Web pages (PHP - V)
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP – Hypertext Preprocessor.
PHP using MySQL Database for Web Development (part II)
Web Basics: HTML/CSS/JavaScript What are they?
Introduction to Dynamic Web Programming
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Web UI Basics ITM 352.
PHP Introduction.
14-мавзу. Cookie, сеанс, FTP и технологиялари
Lonely as a Cloud  A LONELY PPT.
HTTP Request Method URL Protocol Version GET /index.html HTTP/1.1
Intro to PHP.
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
PHP State.
PHP-II.
Presentation transcript:

Some HTTP Examples

A utility which shows all data from incoming requests is here: It is defined as follows: <?php echo " SERVER variables: "; foreach ($_SERVER as $name => $value) { echo "$name = $value "; } echo " GET variables: "; foreach ($_GET as $name => $value) { echo "$name = $value "; } echo " POST variables: "; foreach ($_POST as $name => $value) { echo "$name = $value "; } echo " COOKIE variables: "; foreach ($_COOKIE as $name => $value) { echo "$name = $value "; } ?>

A program which delivers a web-page in the user’s preferred language It is defined as follows: <?php function answerInEnglish() {?> Hello <?php } function answerInFrench() {?> Bonjour <?php } function giveDefaultAnswer() {?> Default greeting <?php } $language=$_SERVER['HTTP_ACCEPT_LANGUAGE']; if ($language=='en-ie') { answerInEnglish(); } else if ($language=='fr') { answerInFrench(); } else { giveDefaultAnswer(); } ?>

Consider this page: It is defined as follows: <?php function answerInEnglish() {?> Hello <?php } function answerInFrench() {?> Bonjour <?php } function giveDefaultAnswer() {?> Default greeting <?php } $language=$_SERVER['HTTP_ACCEPT_LANGUAGE']; if ($language=='en-ie') { answerInEnglish(); } else if ($language=='fr') { answerInFrench(); } else { giveDefaultAnswer(); } ?>

Consider this web-page It contains the following: Wordsworth I wandered lonely as a cloud That floats on high o'er vales and hills

When we try to view this page, we see this, because the tags in the file are not recognized

Now consider this file, which has a different name but contains exactly the same text: It contains the following: Wordsworth I wandered lonely as a cloud That floats on high o'er vales and hills

When we try to view this page, we see this, because the tags in the file are treated as XML tags

See what happens when we use telnet to access the poem.html file The response message contains this header line: Content-Type: text/html

See what happens when we use telnet to access the poem.xml file The response message contains this header line: Content-Type: text/xml

The different behaviour shown by a browser when we view the two files poem.xml and poem.html is caused by these two different headers The header Content-Type: text/html tells the browser to treat the data in the body of the response message as a HTML file The header Content-Type: text/xml tells the browser to treat the data in the body of the response message as a XML file

Consider this PHP program which outputs the XML for the poem It contains the following: <?php echo “ ”; echo “ Wordsworth ”; echo “ ”; echo “ I wandered lonely as a cloud ”; echo “ That floats on high o'er vales and hills ”; echo “ ”; ?>

When we try to view this page, we see this, because the tags in the file are not recognized

Let’s use telnet to try to view the same page Notice that the response message contains the header Content-Type: text/html This is why the browser did not recognize the tags

Now consider this PHP program which outputs a header before it outputs the XML text for the poem It contains the following: <?php header(“Content-Type: text/xml”); echo “ ”; echo “ Wordsworth ”; echo “ ”; echo “ I wandered lonely as a cloud ”; echo “ That floats on high o'er vales and hills ”; echo “ ”; ?>

Let’s use telnet to ask for the page created by this new PHP program Notice that the response message contains the header Content-Type: text/xml This means that a browser should recognize that the tags are XML tags

When this page in a browser, the browser does indeed recognize that the tags are XML tags