Download presentation
Presentation is loading. Please wait.
1
Web Database Programming Input Validation
2
User Input on the Web Web browser built-in mechanisms –HTML Forms HTTP POST method –Hyperlinks HTTP GET method E.g. http://books.slashdot.org/article.pl?sid=02/06/11/2027240 &tid=169&tid=6 http://books.slashdot.org/article.pl?sid=02/06/11/2027240 &tid=169&tid=6 Browser plug-ins –User needs to install plug-in software Difficult for universal deployment –E.g. flash, Java applet
3
HTML Form Container for UI controls –E.g. button, checkbox, etc. Action: the URL of a program on the Web server that will receive the form data –E.g. PHP, CGI program, JSP, ASP, etc. Method: the manner form data are sent over –“POST” or “GET”
4
INPUT controls type attribute –test, password, checkbox, radio, submit, reset, button, hidden name attribute value attribute onclick –Can specify some Javascript code here E.g. for client-side validation Name: Email: Male Female
5
SELECT control Create a menu Must contain OPTION controls Can select multiple items Apple Orange Banana Cherry Pear Grape
6
More Controls More INPUT types TEXTAREA BUTTON Check HTML documentation
7
PHP form data processing Data user entered are sent to PHP program specified by Action attribute –Method: POST, or GET (data append to URL) In that PHP program, a data array is then automatically created –$_POST, or $_GET Data of individual control can be accessed with the name of the control as key –E.g. $_POST[“username”]
8
Input Validation Validate HTML form input from users Error: user input do not match the expected input –E.g. expect zip code, user input street name Finding ErrorsReport Error User correct errors
9
Types of Input Validation Server-side validation –Validation is done by the server E.g. with PHP –More thorough, can check with data E.g. credit card Client-side validation –Validation is done by the browser E.g. with Javascript –More interactive, reduce network load
10
Validation Strategy Validate field by field –Immediate stop and report error is one is found Batch Validation –Continue to validate until all errors found –Report all errors at once
11
Batch Validation with PHP See http://www.albany.edu/~hy973732/cours es/RISP566/Input.html http://www.albany.edu/~hy973732/cours es/RISP566/Input.html
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.