Website Development with PHP and MySQL Saving Data.

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?
23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
24-Aug-14 HTML Forms. 2 What are forms? is just another kind of HTML tag HTML forms are used to create (rather primitive) GUIs on Web pages Usually the.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
JavaScript Forms Form Validation Cookies CGI Programs.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
Website Development Introducing PHP The PHP scripting language Syntax derives from C, Java and Perl Open Source Links to MySql database.
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.
Using Entities & Creating Forms Jill R. Sommer Institute for Applied Linguistics Kent State University.
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.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
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.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
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 Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Web111a_chapt06.ppt HTML: Section 6 Forms HTML tags: define data input and/or output Define the Input and/or Output on the web page Do not process the.
© 2011 Delmar, Cengage Learning Chapter 9 Collecting Data with Forms.
Internet / Intranet Fall 2000 Class 7. Brandeis University Internet/Intranet Spring Class 7 Agenda Project / Homework Discussion Forms Validating.
Internet / Intranet CIS-536 Class 7. 2 HTML Forms A Method to Allow Users to Pass Information to a CGI Script Forms Allow Information to Be Entered Via:
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
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.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
HTML Forms.
1 HTML Forms
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Week 9 - Form Basics Key Concepts 1. 1.Describe common uses of forms on web pages 2.Create forms on web pages using the form, input, textarea, and select.
ITCS373: Internet Technology Lecture 5: More HTML.
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.
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
Web Technologies Lecture 3 Web forms. HTML5 forms A component of a webpage that has form controls – Text fields – Buttons – Checkboxes – Range controls.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
1 HTML forms (cont.)
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
HTML Forms.
Basic Webpage Design HTML Forms. Objectives Learn how to use HTML to create a form. Explain the concept of forms Know the difference of GET and POST Discuss.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Creating Forms on a Web Page. 2 Introduction  Forms allow Web developers to collect visitor feedback  Forms create an environment that invites people.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
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.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Tutorial 6 Working with Web Forms
Introducing Forms.
Forms, cont’d.
PHP Forms and Databases.
Presentation transcript:

Website Development with PHP and MySQL Saving Data

What you will achieve this week! Submitting data to the server Saving data on a server using files

: Customer browser request service access page interpret set data present html return html get data databasescripting language web server Reminder of the general process

What can we do with Forms? Standard HTML tags which: –Collect user input –Specify where to send the input –Specify how to send the input to be processed HTML tags simply provide an interface to allow user interaction Input is handled by a separate script or program: –On the server e.g. via PHP, ASP, CGI etc. –In the browser e.g. JavaScript

More Input Types Radio buttons Choose ONE of the following: A B C Check boxes Choose ANY, ALL or NONE of the following: A B C

Even More Input Types Drop-down menus Text area

Secret Stuff? Passwords Care to give us a password? Hidden fields

Submit and Reset B uttons The submit button sends form data to be processed The reset button returns fields to original state

How to get data from a form to a program Specify how to send the form data –Specified with the method attribute –GET or POST or –If not specified – default is GET Specify where to send the form data –Specified by the action attribute –Usually a script or program – can be local or full URL

The GET Method Client makes an HTTP GET request for a script –Form data is appended to the script URL as name/value pairs – a querystring –The script has access to values sent in the querystring In addition –Input data can be hard-coded directly in a URL No need for a form –Results can be bookmarked

The POST Method Client makes an HTTP POST request for a script –Form data is sent as name/value pairs in the body of the request In addition –Useful for large amounts of data Browser may truncate a long querystring –Data is not visible in the URL –Results cannot be bookmarked

Form Processing Scripts Scripts are run by the web server via a web server application –CGI, PHP, ASP, ColdFusion etc… Scripts can be written in almost any language –PHP, VBScript, Perl, CFML etc… –Language may depend on web server application(s) Scripts receive form input from via GET or POST –Process input based on instructions in the script Create an message Perform database query Write information to a file Generate a web page

Form Processing Query database? Name: Arnold Comments: “Nice website!"... User submits form to web server Web server passes form data to processing script Write a file? Send ? Return a web page?

Submitting data to server through forms Simple examples that echo the submitted data back

: customer simpleTextBox.htmwebServerechoName.php enter name submit submit(echoName.php3) open($name) display

Name test a PHP page to process the form a variable to pass to the PHP page

echoName.php

: customer calculator.htmwebServercalculatorResult.php enter numbers submit submit(calculatorResult.php3) open($num1,$num2) display

Number 1 Number 2 test

calculatorResult.php

Saving data using files

: customer nameAddress.htmwebServersaveAddress.phpnameAddress enter name enter address submit submit(saveAddress.php) open($name,$address) open write close display

int fopen (string filename, string mode) mode may be any of the following:  'r' - Open for reading only; place the file pointer at the beginning of the file.  'r+' - Open for reading and writing; place the file pointer at the beginning of the file.  'w' - Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.  'w+' - Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.  'a' - Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.  'a+' - Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.

string sprintf (string format [, mixed args...]) The format string is composed of zero or more directives: ordinary characters (excluding %) that are copied directly to the result, and conversion specifications, each of which results in fetching its own parameter. b - the argument is treated as an integer, and presented as a binary number. c - the argument is treated as an integer, and presented as the character with that ASCII value. d - the argument is treated as an integer, and presented as a decimal number. f - the argument is treated as a double, and presented as a floating-point number. o - the argument is treated as an integer, and presented as an octal number. s - the argument is treated as and presented as a string. e.g. sprintf(“%d is the number of %s in a %y”, 12, “months”, “year”) results in “12 is the number of months in a year”

Name Address Test

saveAddress.php

Guestbook Application We need: A form A file (or database table) to hold the data entered via the form Some means of reading the data from the file so that we can see it We will look into this case study further when we move onto databases.

So, what have we got so far? A means of collecting data from the user A means of transmitting it to the server A means of recording it on the server