Lecture 9 Server Browser Interactions

Similar documents
CSE 154 LECTURE 9: SUBMITTING DATA (POST)

CSE 154 LECTURE 9: SUBMITTING DATA (POST)

CSE 154 LECTURE 19: FORMS AND UPLOADING FILES

1 Form Basics CSC309

Web Programming Step by Step

Lecture 9 & 10 PHP - II

MORE JAVASCRIPT AND FORMS

Table of contents. DMXzoneUniformManual DMXzone

Web Programming Step by Step

Reset Buttons. More forms. Grouping input: <fieldset>,<legend> fieldset groups related input fields, adds a border; legend supplies a caption

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

Web Development. With PHP. Web Development With PHP

Web Site Development with HTML/JavaScrip

Dreamweaver: Web Forms

COMS 359: Interactive Media

File uploading in PHP

Sections and Articles

Web development using PHP & MySQL with HTML5, CSS, JavaScript

Static Webpage Development

Outline. Introducing Form. Introducing Forms 2/21/2013 INTRODUCTION TO WEB DEVELOPMENT AND HTML

Scoutbook Tutorial for Parents

File uploading in PHP

An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development Form Validation Creating templates

Shankersinh Vaghela Bapu Institue of Technology

Web Site Design and Development Lecture 23. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM

Table of contents. DMXzone Ajax Form Manual DMXzone

ABOUT WEB TECHNOLOGY COURSE SCOPE:

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

University of Washington, CSE 190 M Homework Assignment 4: NerdLuv

Web Design & Dev. Combo. By Alabian Solutions Ltd , 2016

Nick Terkay CSCI 7818 Web Services 11/16/2006

Unit 5: Computer Networking CS 101, Fall 2018

Lecture 6: More Arrays & HTML Forms. CS 383 Web Development II Monday, February 12, 2018

University of Washington, CSE 154 Homework Assignment 7: To-Do List

WEB DESIGNING COURSE SYLLABUS

GRAPHIC WEB DESIGNER PROGRAM

Web Designing Course

powered by Series of Tubes Senator Ted Stevens talking about the Net Neutrality Bill Jul 17, powered by

CGI Architecture Diagram. Web browser takes response from web server and displays either the received file or error message.

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Alpha College of Engineering and Technology. Question Bank

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

Web Engineering (CC 552)

Web Architecture Review Sheet

Application Development in Web Mapping 1.

Website Development with HTML5, CSS and Bootstrap

Student, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6

ReST 2000 Roy Fielding W3C

PHP. MIT 6.470, IAP 2010 Yafim Landa

An Overview of Webmail

User Interaction: jquery

CS105 Perl: Perl CGI. Nathan Clement 24 Feb 2014

Creating HTML files using Notepad

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Web Development & SEO (Summer Training Program) 4 Weeks/30 Days

Basics of Web Technologies

Web Development Course (PHP-MYSQL-HTML5.0)

Ministry of Higher Education and Scientific Research

CSC309 Winter Lecture 2. Larry Zhang

1/6/ :28 AM Approved New Course (First Version) CS 50A Course Outline as of Fall 2014

Get in Touch Module 1 - Core PHP XHTML

Zend Zend Certified PHP Developer. Download Full Version :

Overview

CS 380 WEB PROGRAMMING

You can also set the expiration time of the cookie in another way. It may be easier than using seconds.

USQ/CSC2406 Web Publishing

zend. Number: Passing Score: 800 Time Limit: 120 min.

exam. Number: Passing Score: 800 Time Limit: 120 min File Version: Zend Certified Engineer

Deccansoft Software Services

DATABASE SYSTEMS. Introduction to web programming. Database Systems Course, 2016

Table Basics. The structure of an table

CENG 256 Internet Programming Draft

All India Council For Research & Training

Mobile MOUSe WEB SITE DESIGN ONLINE COURSE OUTLINE

CNIT 129S: Securing Web Applications. Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2

Chapter 7:- PHP. Compiled By:- Sanjay Patel Assistant Professor, SVBIT.

Programming the World Wide Web by Robert W. Sebesta


Lecture Overview. IN5290 Ethical Hacking. Lecture 4: Web hacking 1, Client side bypass, Tampering data, Brute-forcing

The main differences with other open source reporting solutions such as JasperReports or mondrian are:

Silver Oak College of Engineering and Technology Information Technology Department Mid Semester 2 Syllabus 6 th IT

E-Business Systems 1 INTE2047 Lab Exercises. Lab 5 Valid HTML, Home Page & Editor Tables

Book IX. Developing Applications Rapidly

PlayerLync Forms User Guide (MachForm)

Website Creating Content

Full Stack Web Developer

Free Websites for Clubs Handbook Comfypage User Guide

Hands-On Perl Scripting and CGI Programming

CSCI 1100L: Topics in Computing Spring 2018 Web Page Project 50 points

CERTIFICATE IN WEB PROGRAMMING

Logging in to the management system.

JAVASCRIPT JQUERY AJAX FILE UPLOAD STACK OVERFLOW

Languages in WEB. E-Business Technologies. Summer Semester Submitted to. Prof. Dr. Eduard Heindl. Prepared by

Document Object Model. Overview

University of Washington, CSE 190 M Homework Assignment 9: Remember the Cow (To-Do List)

CS Exam 1 Review Suggestions - Spring 2017

Free Web Development Tools: The Accessibility Toolbar

REACH 3.0 Website redesign

PHP INTERVIEW QUESTION-ANSWERS

Adobe Dreamweaver CS6 Digital Classroom

Transcription:

Lecture 9 Server Browser Interactions SE-805 Web 2.0 Programming (supported by Google) http://my.ss.sysu.edu.cn/courses/web2.0/ School of Software, Sun Yat-sen University

Outline More HTML Forms Submitting Data Processing Form data in PHP 2 / 25

Reset Buttons When clicked, returns all form controls to their initial values Specify custom text on the button by setting its value attribute 3 / 25

Grouping Input: <fieldset>, <legend> fieldset groups related input fields, adds a border; legend supplies a caption 4 / 25

Styling Form Controls Attribute selector: matches only elements that have a particular attribute value Useful for controls because many share the same element (input) 5 / 25

Hidden Input Parameters An invisible parameter that is still passed to the server when form is submitted Useful for passing on additional state that isn't modified by the user Especially useful when passing parameters between adjacent web requests 6 / 25

Outline More HTML Forms Submitting Data Processing Form data in PHP 7 / 25

Problems with Submitting Data This form submits to our handy params.php tester page The form may look correct, but when you submit it... [cc] => on, [startrek] => Jean-Luc Picard 8 / 25

The value Attribute Value attribute sets what will be submitted if a control is selected [cc] => visa, [startrek] => kirk 9 / 25

URL-encoding Certain characters are not allowed in URL query parameters: Examples: " ", "/", "=", "&" When passing a parameter, it is URL-encoded (reference table) Eric s cool!?" Eric%27s+cool%3F%21" You don't usually need to worry about this: The browser automatically encodes parameters before sending them The PHP $_REQUEST array automatically decodes them... but occasionally the encoded version does pop up (e.g. in Firebug) 10 / 25

Submitting Data to a Web Server Though browsers mostly retrieve data, sometimes you want to submit data to a server Hotmail: Send a message Flickr: Upload a photo Google Calendar: Create an appointment The data is sent in HTTP requests to the server With HTML forms With predefined URLs With Ajax (seen later) The data is placed into the request as parameters 11 / 25

HTTP GET vs. POST Requests GET : asks a server for a page or data if the request has parameters, they are sent in the URL as a query string POST : submits data to a web server and retrieves the server's response if the request has parameters, they are embedded in the request's HTTP packet, not the URL For submitting data, a POST request is more appropriate than a GET GET requests embed their parameters in their URLs URLs are limited in length (~ 1024 characters) URLs cannot contain special characters without encoding Private data in a URL can be seen 12 / 25

Form POST Example 13 / 25

GET or POST? Some PHP pages process both GET and POST requests To find out which kind of request we are currently processing, look at the Global $_SERVER array's "REQUEST_METHOD" element 14 / 25

Uploading Files Add a file upload to your form as an input tag with type of file Must also set the enctype attribute of the form What s going on exactly when you click the submit button? 15 / 25

Outline More HTML Forms Submitting Data Processing Form data in PHP 16 / 25

"Superglobal" Arrays Array $_GET, $_POST $_REQUEST $_SERVER, $_ENV $_FILES $_SESSION, $_COOKIE Description parameters passed to GET and POST requests parameters passed to any type of request information about the web server files uploaded with the web request "cookies" used to identify the user (seen later) PHP superglobal arrays (global variables) contain information about the current request, server, etc. These are special kinds of arrays called associative arrays. 17 / 25

Associative Arrays Associative array (a.k.a. map, dictionary, hash table) : uses non-integer indexes associates a particular index key with a value i.e. key "marty" maps to value "206-685-2181" Syntax for embedding an associative array element in interpreted string: 18 / 25

Processing an Uploaded File in PHP Uploaded files are placed into global array $_FILES, NOT $_REQUEST Each element of $_FILES is itself an associative array, containing: name type size : the local filename that the user uploaded : the MIME type of data that was uploaded, such as image/jpeg : file's size in bytes tmp_name : a filename where PHP has temporarily saved the uploaded file To permanently store the file, move it from this location into some other file 19 / 25

Uploading Details Example: if you upload borat.jpg as a parameter named avatar, $_FILES["avatar"]["name"] will be "borat.jpg" $_FILES["avatar"]["type"] will be "image/jpeg" $_FILES["avatar"]["tmp_name"] will be something like "/var/tmp/phpztr4ti" 20 / 25

Processing Uploaded File, Example Functions for dealing with uploaded files: is_uploaded_file(filename) returns TRUE if the given filename was uploaded by the user move_uploaded_file(from, to) moves from a temporary file location to a more permanent file Proper idiom: check is_uploaded_file, then do move_uploaded_file 21 / 25

Summary More HTML Forms reset, hidden fieldset, legend Submitting Data Value (radio, option) URL-encoding GET vs. POST Uploading files Processing Form data in PHP Superglobal arrays Process uploaded files 22 / 25

Exercises Write a php page to mimic the registration page of Topcoder Get initial html from https://www.topcoder.com/reg/ Convert it to a PHP page, which only shows data you submitted at the top of this page when your first name is Eric, otherwise it shows the message Strangers Forbidden! instead 23 / 25

Further Readings W3C XHTML Controls: http://www.w3.org/tr/html4/interact/forms.html W3Schools HTML forms tutorial http://www.w3schools.com/html/html_forms.asp PHP home page: http://www.php.net/ W3Schools PHP tutorial: http://www.w3schools.com/php/ Practical PHP Programming: http://hudzilla.org/phpwiki/ PHP Cookbook: http://commons.oreilly.com/wiki/index.php/php_cookbook CSS fun with forms: http://www.picment.com/articles/css/funwithforms/ 24 / 25

Thank you! 25 / 25