ITM 352 HTML Forms, Basic Form Processing

Slides:



Advertisements
Similar presentations
PHP Workshop ‹#› Forms (Getting data from users).
Advertisements

FORMs Lesson TBE 540. Prerequisites Before beginning this lesson, the learner must be able to… –Create basic web pages using a text editor and/or a web.
Lecture 14 HTML Forms CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Technologies for web publishing Ing. Václav Freylich Lecture 4.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
Tutorial 6 Working with Web Forms
Form Basics CS Web Data  Most interesting web pages revolve around data  examples: Google, IMDB, Digg, Facebook, YouTube, Rotten Tomatoes  can.
USER INTERACTIONS: FORMS
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
Unit 7 – Working with Forms 1. Creating a form 2. Accessing the submitted data 3. Common operations on forms.
ITM © Port, Kazman1 ITM 352 HTML Forms, Basic Form Processing.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
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.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Forms and Form Controls Chapter What is a Form?
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
CSE 382/ETE 334 Internet and Web Technology Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
BBK P1 Module2010/11 : [‹#›] Forms (Getting data from users)
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
LOGO FORMs in HTML CHAPTER 5 Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC229 Client-Side.
Introduction to HTML Part 3 Chapter 2. Learning Outcomes Identify how to design frames. Explain frames’ attributes. Describe the method on designing forms.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
76 © 1998, 1999, 2000 David T. Gray, Howard Duncan, Jane Kernan Frames When displaying information in a browser, it is sometimes useful to divide the display.
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,
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
1 Review of Form Elements. 2 The tag Used in between tags.  Form elements(text control, buttons, etc.. ) goes here. OR  Form elements(text control,
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Web Page Design Forms! Website Design. Objectives What forms can do The Attributes of the form tag Using Textboxes Textareas Checkboxes Radio buttons.
+ FORMS HTML forms are used to pass data to a server. begins and ends a form Forms are made up of input elements Every input element has a name and value.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Netprog CGI and Forms1 CGI and Forms A detailed look at HTML forms.
HTML Forms.
Week 10: HTML Forms HNDIT11062 – Web Development.
HTML FORMS Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 1.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 6: Creating XHTML Forms Kelly.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
HTML III (Forms) Robin Burke ECT 270. Outline Where we are in this class Web applications HTML Forms Break Forms lab.
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
Day 22, Slide 1 CSE 103 Day 22 Non-students: Please logout by 10:12. Students:
Simple PHP Web Applications Server Environment
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Tutorial 6 Working with Web Forms
How to Write Web Forms By Mimi Opkins.
ITM 352 More on Forms Processing
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Arrays: Checkboxes and Textareas
ITE 115 Creating Web Page Forms
ITM 352 Cookies.
Basic XHTML Tables XHTML tables—a frequently used feature that organizes data into rows and columns. Tables are defined with the table element. Table.
Arrays and files BIS1523 – Lecture 15.
Programming the Web using XHTML and JavaScript
Introducing Forms.
HTML Forms and User Input
Dr. John P. Abraham Professor UTRGV eCommerce CSCI 6314
Forms, cont’d.
CNIT 131 HTML5 - Forms.
Introduction to HTML: Forms
PHP-II.
Presentation transcript:

ITM 352 HTML Forms, Basic Form Processing

Some Inspiration! Perseverance: never giving up Indomitable Spirit: never wanting to give up Perseverance + Indomitable Spirit = Success On Indomitable Spirit: "Try not. Do, or do not. There is no try." – Yoda “If can can. If no can, STILL can” – Hawaiian wisdom

What We Will Cover Today Today we will explore HTML forms in some detail: Details on <FORM> Input types Compound types Some tips for HTML form elements

Form Parts <form action = 'xxx' method = 'yyy'> <form stuff goes here> </form> action is the file you want to go to (could be html or php) method should be either POST or GET

Action An action should be a URI (e.g. a file name in the current folder) or a full web address, e.g. http://www.somewebserver.com/myfile.php) Example: <form action = 'invoice.php'> … </form> This will take the user to the invoice.php page in the current directory when the user presses the submit button. Note: You should always use quotes around the URI in case it has special characters or spaces.

Method The method can be either 'POST' or 'GET'. $_GET and $_POST are arrays built into PHP which make form processing a lot easier. Form variables are stored as keys (elements) of these arrays, indexed by their name To see what is in the array just do a var_dump() e.g. var_dump($_GET); TIP: put var_dump()at the top of form processing files so you can see what is sent from the form

Submit Button Usually you need to have a submit button to invoke a form's action, e.g.: <input type = 'SUBMIT' name = 'the name you want to appear in the POST/GET array' value = 'the label in the button ' >

Example: Login <form action ='invoice.php' method = 'POST'> <input type = 'SUBMIT' name = 'submit_button' value = 'Login'> </form>

Input types (single value) A generic input type looks like this: <input type = '<type>' name = '<the name in the POST/GET array>' value = '<the value you want to set it to>' >

The Basic Input Types Text Password Hidden Radio Checkbox Submit

Login <?php print "logged in " . $_POST['username']; ?> <form action = 'process_login.php' method = 'post'> <input type = 'text' name = 'username'> <input type = 'password' name = 'password'> <input type = 'submit' name = 'submit_button' value = 'login'> </form>

Self-Processing Form Sometimes you want to stay on the same page when processing your forms <form action = '<?= $_SERVER["PHP_SELF"]?>' method = 'post'> </form> is the same as: <form action = '<?php $_SERVER["PHP_SELF"] ?>'method = 'post'> <?= is short for echo when embedding PHP in HTML You can use $PHP_SELF or $_SERVER['PHP_SELF']

Login if( array_key_exists('submit_button', $_POST) ) { print "logged in " . $_POST['username']; } else { ?> <form action = '<?php $_SERVER['PHP_SELF'] ?>' method = 'post'> <input type = 'text' name = 'username'> <input type = 'password' name = 'password'> <input type = 'submit' name = 'submit_button' value = 'login'> </form> <?php } ?>

GET method <form method = 'get'> … </form> GET will show the information being passed between pages as part of the URL. Good tool for error checking However, it is not secure because users can see the full contents of the request. Pages can be cached.

POST method <form method = 'post'> … </form> POST will hide information being passed between pages in the address bar. HINT: use GET for error checking; change to POST when submitting your work More secure than GET Pages won't be cached.

Compound Types Select Text area List box Compound types enable multiple inputs and/or outputs Unlike input types, compound types always use a begin and end tag <select name='a_select_box'> … </select>

Login if( array_key_exists('submit_button', $_POST) ) { print "logged in " . $_POST['username']; } else { ?> <form action = '<?php $_SERVER['PHP_SELF'] ?>' method = 'post'> <select name='username'> <option>Moe</option> <option>Larry</option> <option>Curly</option> </select> <input type = 'password' name = 'password'> <input type = 'submit' name = 'submit_button' value = 'login'> </form> <?php } ?>

Select Boxes Select boxes (aka combo boxes, aka drop-down lists) provide a set of options for the user to choose from. Value is whatever the user chooses when the submit button is pressed If no value parameter is set, the value defaults to the label <SELECT name="a_select_box"> <OPTION value="value_of_thing1">thing1</OPTION> <OPTION value="value_of_thing2">thing2</OPTION> <OPTION value="value_of_thing3">thing3</OPTION> </SELECT>

Text Area Text Area provide a region of size row X cols to display and input text. Value is whatever is in the area when the submit button is pressed <TEXTAREA name="text_box" rows="20" cols="40"> This is some text in the text area. </TEXTAREA>

List Boxes List boxes can be single-select or multiple-select. Example: <select name="listbox" size="3"> <option value="New York" selected>New York</option> <option value="Tokyo">Tokyo</option> <option value="Chicago">Chicago</option> <option value="Detroit">Detroit</option> <option value="Los Angeles">Los Angeles</option> </select> To make it multiple-select add the parameter multiple="multiple" to the <select> tag

Tips and Hints Use single ' ' on the inside, " " around the outside or vice versa Take advantage of PHP by using for/while/foreach to generate multiple form elements and compound types Quotes must be used around anything with spaces