Server-Side Validation Jayden Bryant. What is Server-Side Validation?  Validation of form input done on the server, not the web browser program //Validate.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

FORM VALIDATION Faheem Ahmed Khokhar. FORM VALIDATION Faheem Ahmed Khokhar.
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
JavaScript Forms Form Validation Cookies CGI Programs.
Tutorial 14 Working with Forms and Regular Expressions.
IS 1181 IS 118 Introduction to Development Tools Chapter 4 String Manipulation and Regular Expressions.
. If the PHP server is an server or is aware of which server is the server, then one can write code that s information. –For example,
Client-Side programming with JavaScript 3
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
MIT AITI 2004 JSP – Lecture 2 Get and Post Requests.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
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.
Chapter 4 Handling User Input PHP Programming with MySQL 2nd Edition
JavaScript Form Validation
PHP : Hypertext Preprocessor
1 Chapter 6 – Creating Web Forms and Validating User Input spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Form Handling.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
Tutorial 14 Working with Forms and Regular Expressions.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Validation Controls. Validation Server Controls These are a special type of Web server control. They significantly reduce some of the work involved in.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Includes and Dates.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
A little PHP. Enter the simple HTML code seen below.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Using Client-Side Scripts to Enhance Web Applications 1.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Mark Dixon 1 03 – Passing Data between pages: Forms, Sessions, & Query Strings.
Website Development with PHP and MySQL Saving Data.
Internet Information Systems Writing to Databases and Amending Data.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
If statements and validation. If statement In programming the if statement allows one to test certain conditions and respond differently depending on.
Validation "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
 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.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
4343 X2 – Outline The Domain Name System The Web.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
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.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Internet Naming Service: DNS* Chapter 5. The Name Space The name space is the structure of the DNS database –An inverted tree with the root node at the.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
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,
Radoslav Georgiev Telerik Corporation
Simple PHP Web Applications Server Environment
PHP Hypertext Preprocessor
Web Programming– UFCFB Lecture 17
Working with Forms and Regular Expressions
Conditions and Ifs BIS1523 – Lecture 8.
JavaScript Form Validation
Presentation transcript:

Server-Side Validation Jayden Bryant

What is Server-Side Validation?  Validation of form input done on the server, not the web browser program //Validate the Surname If ($surname == “”) print( “The surname field cannot be blank.”);

Differences between Client and Server Side Validation  Client-Side No round trip to server = quicker validation, instant feedback to userNo round trip to server = quicker validation, instant feedback to user User may skip client-side validation by turning off java scriptUser may skip client-side validation by turning off java script  Server-Side Ensures 100% validation of input even if front end validation failsEnsures 100% validation of input even if front end validation fails User cannot skip server-side validationUser cannot skip server-side validation Ensures that improper data sent will be filtered correctly, a detailed error message can be sent back to userEnsures that improper data sent will be filtered correctly, a detailed error message can be sent back to user Takes longer time to vaildate – information must do a round trip to the server.Takes longer time to vaildate – information must do a round trip to the server.

What we shall Discuss  Methods used when validating different form data  Number validation  URL validation  Validation

Common Validation functions  ereg () function <?php $username = (jayden2); If (ereg ('[^A-Za-z]', $username)){ echo "Usernames must contain only letters."; } else {echo "$username is a valid username.";} ?>  !ereg () function if ($validate) { $text = ($n); print " entered is $text. "; if echo (" must conatain the symbol else echo ("Good job, contains an } To example

Validating Numbers  is_numeric() function Checks to see if input is numericChecks to see if input is numeric is_numeric allows:is_numeric allows: Integers e.g Integers e.g Scientific notations e.g. 15e4Scientific notations e.g. 15e4 Floating points e.g Floating points e.g Hexadecimal e.g. 2xffHexadecimal e.g. 2xff Negative numbers e.g. -56Negative numbers e.g. -56 if (!is_numeric($n)) print “Does not conform to function"; else print "Validation passed!! Input was: $n"; Example

Validating URL’s  Parse_url: function parses a URL and returns an associative array containing any of the various components of the URL that are present.  scheme - e.g. http  host  port  user  pass  path  query - after the question mark ?  fragment - after the hashmark # Example: Example: ssage parse_url

Validating URL’s  function_exists: Return TRUE if the given function has been defined  checkdnsrr: Check DNS records corresponding to a given Internet hostname or IP address type may be any one of: A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR or ANY. The default is MX. URL code

URL Validation Code  <?php  $bits = parse_url($url);  if ($bits["scheme"] != "http")  print "URL must begin with  elseif (empty($bits["host"]))  print "URL must include a host name.";  elseif (function_exists('checkdnsrr') && !checkdnsrr($bits["host"], 'A'))  print "Host does not exist.";  else  echo ("URL: $bits Exists");  ?> URL Example

Validating  Empty (var) – Determines whether a variable is empty  strlen - Get string length Returns the length of the given stringReturns the length of the given string  Getmxrr – Check if there is a record of the domain as a mail exchanger (MX)  Gethostbyname -  Gethostbyname - Get the IP address corresponding to a given Internet host name

Validating  substr ( string string, int start [, int length] ) Returns part of a string returns the portion of string specified by the start and length parameters.  string strstr ( string haystack, string needle ) Finds the first occurence of the string Returns part of haystack string from the first occurrence of needle to the end of haystack If needle is not found, returns false Code

Validation code  {  $valid Expr =  "^[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$%&_-])*".   if (empty($ ))  {  print "The field cannot be blank";  $printFlag = false;  }  elseif (!eregi($valid Expr, $ ))  {  print "The must be in the format.";  $printFlag = false;  }  elseif (strlen($ ) >30)  {  print "The address can be no longer than 30 characters.";  $printFlag = false;  }

Validation code  elseif (function_exists("getmxrr") && function_exists("gethostbyname"))  {  $maildomain = substr(strstr($ , 1);  if (!(getmxrr($maildomain, $temp) || gethostbyname($maildomain) !=$maildomain))  {  print "The domain does not exist.";  $printFlag = false;  }  else $printFlag = true;  }  if ($printFlag == true) {  print " address: $ exists";  }  ?> Example

Class Quiz  When using is_numeric function, what are the 5 legal number formats? Integers e.g Integers e.g Scientific notations e.g. 15e4Scientific notations e.g. 15e4 Floating points e.g Floating points e.g Hexadecimal e.g. 2xffHexadecimal e.g. 2xff Negative numbers e.g. -56Negative numbers e.g. -56 Question 2

Class Quiz: Qu 2  What is a major difference between client-side and server-side validation? Question 3

Class Quiz: Qu 3  What does the function parse_url do? Returns the different components of which the URL is made up of e.g.Returns the different components of which the URL is made up of e.g. scheme - e.g. httpscheme - e.g. http hosthost portport useruser passpass pathpath query - after the question mark ?query - after the question mark ? fragment - after the hashmark #fragment - after the hashmark # Question 4

Class Quiz: Qu 5  What does the function strstr return? Finds the first occurence of the string Returns part of haystack string from the first occurrence of needle to the end of haystack If needle is not found, returns false Question 5

Class Quiz: Qu 6  What does the function empty check? If the variable is emptyIf the variable is empty

Validation Complete