tailieunhanh - Lecture Introduction to web engineering - Lec 27: Validating user input
Lec 27 - Validating user input. After studying this chapter you will be able to understand: Super global variables, passing form data, passing data with sessions, regular expressions in PHP, validating user input at server, string functions. | Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1 Super Global variables Passing form data Passing data with sessions Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 2 2 Department of Computer Science, CIIT Islamabad. Regular expressions in PHP Validating user input at server String functions Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 3 3 Department of Computer Science, CIIT Islamabad. A regular expression is a concise notation to describe patterns in strings Regular expressions provide the foundation for describing or matching data according to defined syntax rules Example: |^[0-9]{2}-[0-9]{2}-[0-9]{4}$| Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 4 |^[0-9]{2}-[0-9]{2}-[0-9]{4}$| Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 5 Start and end of RE Sub pattern Sub pattern Sub pattern Start matching from the start Match the end of the string . | Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1 Super Global variables Passing form data Passing data with sessions Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 2 2 Department of Computer Science, CIIT Islamabad. Regular expressions in PHP Validating user input at server String functions Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 3 3 Department of Computer Science, CIIT Islamabad. A regular expression is a concise notation to describe patterns in strings Regular expressions provide the foundation for describing or matching data according to defined syntax rules Example: |^[0-9]{2}-[0-9]{2}-[0-9]{4}$| Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 4 |^[0-9]{2}-[0-9]{2}-[0-9]{4}$| Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 5 Start and end of RE Sub pattern Sub pattern Sub pattern Start matching from the start Match the end of the string Sub pattern with fixed character Allowed characters length [0-9] {2} Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 6 Start and end of the RE: optional, || Sub-patterns: range of allowed characters Allowed length Sub-patterns with fixed character: Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 7 Matching from the start: 1212-12-2014 Matching till end: 12-12-2014123 For exact match we should use both ^ and $ Pattern exists if do not match from start Pattern exists if do not match till end ^: match strings that start with the given pattern $: match strings that end with the given pattern -: means a range of characters [ ]: makes a class of characters [^ ]: negates the class of character Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 8 Quantifiers: {n}: matches a character, class or sub-pattern for n times { n, m}: matches a character, class or sub-pattern for minimum n times and maximum m times Basharat .
đang nạp các trang xem trước