HTML Form and PHP IST2101. 2 Review of Previous Class HTML table and PHP array Winner is chosen automatically using rand() function.

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
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.
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
Video, audio, embed, iframe, HTML Form
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
Computing Concepts Advanced HTML: Tables and Forms.
PHP and SQL Server: Queries IST2101. Project Report 4 SQL Queries Due Sunday, 4/5 at 11:59pm Instructions on how to access team webspace and SQL database.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
1 ADVANCED MICROSOFT WORD Lesson 15 – Creating Forms and Working with Web Documents Microsoft Office 2003: Advanced.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
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.
ITM © Port, Kazman1 ITM 352 HTML Forms, Basic Form Processing.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
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.
HTML Forms What is a form.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
DAT602 Database Application Development Lecture 14 HTML.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Suzanne J. Sultan Javascript Lecture 2. Suzanne J. Sultan function What is a function> Types of functions:  Function with no parameters  Function with.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Website Development with PHP and MySQL Saving Data.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
HTML Forms.
LOGO FORMs in HTML CHAPTER 5 Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC229 Client-Side.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
HTML Table and PHP Array
HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
ITCS373: Internet Technology Lecture 5: More HTML.
HTML and FORMS.  A form is an area that can contain form elements.  Form elements are elements that allow the user to enter information (like text fields,
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,
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen randomly using rand() function.
Programming Assignment 3 Add forms in your web page so that visitors can add a comment about your web page – Example:
CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted.
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.
PHP Form Introduction Getting User Information Text Input.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
PHP and SQL Server: Queries IST2101. Steps to Design PHP Pages to Answer User Queries 1.Query generation – What SQL query do we need to retrieve the desired.
Web Page Design Forms! Website Design. Objectives What forms can do The Attributes of the form tag Using Textboxes Textareas Checkboxes Radio buttons.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
HTML Creating Forms on a Web Page. 2 Objectives  Discuss the process of creating a form  Distinguish between data input controls and text input controls.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 6: Creating XHTML Forms Kelly.
HTML FORM Lab Exercise IST Guideline Add forms in your web page so that visitors can add a comment about your web page Forms should include the.
HTML FORM AND PHP IST 210: Organization of Data IST210 1.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
HTML FORM. Form HTML Forms are used to select different kinds of user input. HTML forms are used to pass data to a server. A form can contain input elements.
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,
HTML Tables Tables are defined with the tag. A table is divided into rows (with the tag), and each row is divided into data cells (with the tag). td stands.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
HTML FORM Assignment P4 IST Guideline Add forms in your web page so that visitors can add a comment about your web page Forms should include the.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Validation and Building Small Apps
Introducing Forms.
Forms, cont’d.
PHP-II.
Presentation transcript:

HTML Form and PHP IST2101

2 Review of Previous Class HTML table and PHP array Winner is chosen automatically using rand() function.

Today’s Objectives Learn interaction with users using HTML Form IST2103

Input Parameter Using Form Pick a student (0-4)! <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); if (!empty($_POST['studentID'])){ $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; } ?> IST2104

Input Parameter Using Form Pick a student (0-4)! <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); if (!empty($_POST['studentID'])){ $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; } ?> IST2105 Generate the form

Input Parameter Using Form IST2106 Pick a student (0-4)! <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); if (!empty($_POST['studentID'])){ $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; } ?> The value input into the textbox will be assigned to variable studentID and will be stored in POST container. In PHP segment, we can retrieve the value this variable using $_POST[‘studentID’]. Note, the variable name should be exactly the same (case sensitive)!

Input Parameter Using Form IST2107 Pick a student (0-4)! <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); if (!empty($_POST['studentID'])){ $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; } ?> We retrieve the value and assign to variable $v. Finally, output the student name with index $v.

Overview of the whole process Request: date_form.php Form submitted to: Date_form.php IST2108 Webspace User

Try it yourself IST2109 Pick a student (0-4)! <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); if (!empty($_POST['studentID'])){ $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; } ?> lottery2.php

A More General Case IST Input form in one page; PHP response in another page

IST21011 Pick a student (0-4)! <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); if (!empty($_POST['studentID'])){ $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; } ?> Pick a student (0-4)! lottery3.php <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; ?> process_lottery3.php lottery2.php Separate into a form page and a process page

IST21012 So what happens if I directly visit The variables do not have values

Overview of the whole process Request: date_form.php Form submission to: Date_form.php IST21013 Webspace User

Try it yourself IST21014 Pick a student (0-4)! lottery3.php <?php $lastname = array ('Smith', 'Kim', 'Davis', 'Miller', 'Taylor'); $firstname = array('John', 'Anthony', 'Richard', 'Thomas', 'Jessica'); $v = $_POST['studentID']; echo "Today's Winner is: ".$firstname[$v]." ".$lastname[$v]; ?> process_lottery3.php

Why Are Forms Important to You? Database query will be sent through forms –Keyword –A set of possible values Database query conditions will be specified through forms –Including or excluding a condition IST21015

Forms Forms enable server-user interaction –Allow users to input data –User inputs sent to a server program –The server program processes the query Examples: –User login –User registration –Search Usually three steps –Input page, visual part of the form, coded in HTML –Form validation, a program to check the data before it enters the server (often JavaScript) –Form processing, a program that accepts and processes the input IST21016

Forms Formal definition –A form is an area that can contain data input elements Text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc Defined with the tag and a set of attributes –name: the name of the form –action: the program that will processes the form –method: how this form will be submitted IST21017

Form Definition This line says: –The form will be processed by “process_lottery3.php” –By clicking “go”, a user sends an HTTP request to “process_lottery3.php” –All the form data is attached to the HTTP request via “post” method You can also use “get” method For difference between “post” and “get”, see IST21018

Form Elements The most used form element tag is the tag –The type of input is specified with the type attribute Text, Dropdown List, Radio button, Checkbox, Submit –The name attribute is usually used by validation or processing code to retrieve the input data. In most cases, it has nothing to do with displaying the element IST

Form Elements: Text Fields Text fields are used when you want the user to type letters, numbers, etc. in a form Use value attribute to preset some text in the field IST21020

Form Elements: Submit Button Submit button –When the user clicks the "Submit" button, the content of the form is sent to another file, which is defined by action attribute of the tag IST21021

Form Elements: Radio Buttons Radio Buttons are used when you want the user to select one of a limited number of choices IST21022 Pick a student (0-4)! Value that will be passed to the process pageValue show on the page

Form Elements: Checkboxes Checkboxes are used when you want the user to select one or more options of a limited number of choices. IST21023 Pick a student (0-4)!

Form Elements: Dropdown List Let the user choose from a set of given options. IST Pick a student (0-4)!

Lab Exercise Add forms in your web page so that visitors can add a comment about your web page Forms should include the following elements: – A text field – A textarea field – A set of radio button – A dropdown menu – A submit button Write a PHP file to display all data a visitor inputs in a new page after the submit button is clicked – Test the input of radio button and print out different messages IST21025

IST

Get Started IST21027 Name: comment.php <?php $userName=$_POST["username"]; echo "Hello $userName ! "; ?> process_comment.php

Hints Modify comment.php for form input – A text field for name – A button for Yes/No – A textarea for comment Learn this format by yourself – A dropdown list for rating Modify process_comment.php to process form – Echo name – Use “IF/ELSE” to echo “like” or “do not like” – Echo comment – Echo rating IST21028

Advanced Requirement (Optional) Think about how to better get input aligned as shown in the screenshots? – Hint: use table IST21029