SlideShare a Scribd company logo
1 of 10
FORM VALIDATION
BUILT-IN FUNCTIONS
TOPICS TO BE COVERED
• Metacharacters
• Php Function filter_var()
muhammadabaloch
METACHARACTERS
• Metacharacters are characters with a special meaning:
Metacharacter Description
w Finds word character i.e. (alphabets and
number)
W Finds non-word character i.e. (Special
Characters)
d Finds digit i.e. (Numbers)
D Finds non-digit character i.e. (alphabets
and Special Characters)
muhammadabaloch
METACHARACTERS
$string = "ali123"; // Characters+ number
$patt = "/w/";
$string = "$ _-+"; // Special Characters
$patt = "/W/";
$string = "$*&"; // number
$patt = "/d/"; // return false
$string = “1234"; //alphabets and Special Characters
$patt = "/D/";
muhammadabaloch
PHP FUNCTION filter_var()
• The filter_var() function filters a variable with the specified filter.
• Returns the filtered data on success or FALSE on failure.
Syntax
filter_var( variable , filter , options )
Parameter Description
variable Required. Specifies the variable to filter
filter Optional. Specifies the ID of the filter to
use. Default is FILTER_SANITIZE_STRING.
options Optional. Specifies an associative array of
flags/options or a single flag/option. Check
each filter for possible options and flags
muhammadabaloch
PHP FUNCTION filter_var()
• Number (Integer) Validation
• Number (Integer) validation with range
• Validation String with Regular Expression
• Email Validation
muhammadabaloch
PHP FUNCTION filter_var()
• Number (Integer) Validation
<?php
$integer="6234";
if( filter_var ( $integer , FILTER_VALIDATE_INT ) ) {
echo "Integer Number";
}
else {
echo "Not Integer";
}
?>
muhammadabaloch
PHP FUNCTION filter_var()
• Number (Integer) Validation with range
<?php
$integer ="6234";
if( filter_var( $integer , FILTER_VALIDATE_INT,
array( "options"=>array("min_range"=>1,"max_range"=>5000 ) ) ) )
{
echo "Integer Number";
}else {
echo "Not Integer";
}
?>
muhammadabaloch
PHP FUNCTION filter_var()
• String Validation with Regular Expression
<?php
$string = “hidaya trust”;
$regExp = "/^[a-zA-Z ]{1,}$/";
if((filter_var($string,FILTER_VALIDATE_REGEXP,
array("options"=>array("regexp"=>$regExp)))))
{
echo "Expression Matched";
}
else {
echo "Expression Not Matched";
}
?> muhammadabaloch
PHP FUNCTION filter_var()
• Email Validation
<?php
$email = “shoro_asif@yahoo.com";
if(filter_var( $email, FILTER_VALIDATE_EMAIL )) {
echo "Valid Email";
}
else{
echo "invalid Email";
}
?>
muhammadabaloch

More Related Content

Viewers also liked

String functions and operations
String functions and operations String functions and operations
String functions and operations Mudasir Syed
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4Mudasir Syed
 
Java script lecture 1
Java script lecture 1Java script lecture 1
Java script lecture 1Mudasir Syed
 
Css presentation lecture 1
Css presentation lecture 1Css presentation lecture 1
Css presentation lecture 1Mudasir Syed
 
Css presentation lecture 3
Css presentation lecture 3Css presentation lecture 3
Css presentation lecture 3Mudasir Syed
 
Javascript lecture 3
Javascript lecture 3Javascript lecture 3
Javascript lecture 3Mudasir Syed
 
String functions and operations
String functions and operations String functions and operations
String functions and operations Mudasir Syed
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2Mudasir Syed
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminMudasir Syed
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1 Mudasir Syed
 
Web forms and html lecture Number 5
Web forms and html lecture Number 5Web forms and html lecture Number 5
Web forms and html lecture Number 5Mudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2Mudasir Syed
 
Web forms and html lecture Number 2
Web forms and html lecture Number 2Web forms and html lecture Number 2
Web forms and html lecture Number 2Mudasir Syed
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1Mudasir Syed
 

Viewers also liked (20)

String functions and operations
String functions and operations String functions and operations
String functions and operations
 
Dreamweaver cs6
Dreamweaver cs6Dreamweaver cs6
Dreamweaver cs6
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4
 
Java script lecture 1
Java script lecture 1Java script lecture 1
Java script lecture 1
 
Css presentation lecture 1
Css presentation lecture 1Css presentation lecture 1
Css presentation lecture 1
 
Javascript 2
Javascript 2Javascript 2
Javascript 2
 
Css presentation lecture 3
Css presentation lecture 3Css presentation lecture 3
Css presentation lecture 3
 
Javascript lecture 3
Javascript lecture 3Javascript lecture 3
Javascript lecture 3
 
Dom in javascript
Dom in javascriptDom in javascript
Dom in javascript
 
String functions and operations
String functions and operations String functions and operations
String functions and operations
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
PHP mysql Sql
PHP mysql  SqlPHP mysql  Sql
PHP mysql Sql
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdmin
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1
 
Web forms and html lecture Number 5
Web forms and html lecture Number 5Web forms and html lecture Number 5
Web forms and html lecture Number 5
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Web forms and html lecture Number 2
Web forms and html lecture Number 2Web forms and html lecture Number 2
Web forms and html lecture Number 2
 
Ajax
Ajax Ajax
Ajax
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1
 

More from Mudasir Syed

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php Mudasir Syed
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1Mudasir Syed
 
Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDFMudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2Mudasir Syed
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHPMudasir Syed
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2Mudasir Syed
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joinsMudasir Syed
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction databaseMudasir Syed
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagramMudasir Syed
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatinMudasir Syed
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functionsMudasir Syed
 
Form validation server side
Form validation server side Form validation server side
Form validation server side Mudasir Syed
 
Form validation client side
Form validation client side Form validation client side
Form validation client side Mudasir Syed
 
Javascript lecture 4
Javascript lecture  4Javascript lecture  4
Javascript lecture 4Mudasir Syed
 

More from Mudasir Syed (17)

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1
 
Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDF
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHP
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2
 
Sql select
Sql select Sql select
Sql select
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
 
Form validation server side
Form validation server side Form validation server side
Form validation server side
 
Form validation client side
Form validation client side Form validation client side
Form validation client side
 
Javascript lecture 4
Javascript lecture  4Javascript lecture  4
Javascript lecture 4
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

Form validation with built in functions

  • 2. TOPICS TO BE COVERED • Metacharacters • Php Function filter_var() muhammadabaloch
  • 3. METACHARACTERS • Metacharacters are characters with a special meaning: Metacharacter Description w Finds word character i.e. (alphabets and number) W Finds non-word character i.e. (Special Characters) d Finds digit i.e. (Numbers) D Finds non-digit character i.e. (alphabets and Special Characters) muhammadabaloch
  • 4. METACHARACTERS $string = "ali123"; // Characters+ number $patt = "/w/"; $string = "$ _-+"; // Special Characters $patt = "/W/"; $string = "$*&"; // number $patt = "/d/"; // return false $string = “1234"; //alphabets and Special Characters $patt = "/D/"; muhammadabaloch
  • 5. PHP FUNCTION filter_var() • The filter_var() function filters a variable with the specified filter. • Returns the filtered data on success or FALSE on failure. Syntax filter_var( variable , filter , options ) Parameter Description variable Required. Specifies the variable to filter filter Optional. Specifies the ID of the filter to use. Default is FILTER_SANITIZE_STRING. options Optional. Specifies an associative array of flags/options or a single flag/option. Check each filter for possible options and flags muhammadabaloch
  • 6. PHP FUNCTION filter_var() • Number (Integer) Validation • Number (Integer) validation with range • Validation String with Regular Expression • Email Validation muhammadabaloch
  • 7. PHP FUNCTION filter_var() • Number (Integer) Validation <?php $integer="6234"; if( filter_var ( $integer , FILTER_VALIDATE_INT ) ) { echo "Integer Number"; } else { echo "Not Integer"; } ?> muhammadabaloch
  • 8. PHP FUNCTION filter_var() • Number (Integer) Validation with range <?php $integer ="6234"; if( filter_var( $integer , FILTER_VALIDATE_INT, array( "options"=>array("min_range"=>1,"max_range"=>5000 ) ) ) ) { echo "Integer Number"; }else { echo "Not Integer"; } ?> muhammadabaloch
  • 9. PHP FUNCTION filter_var() • String Validation with Regular Expression <?php $string = “hidaya trust”; $regExp = "/^[a-zA-Z ]{1,}$/"; if((filter_var($string,FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>$regExp))))) { echo "Expression Matched"; } else { echo "Expression Not Matched"; } ?> muhammadabaloch
  • 10. PHP FUNCTION filter_var() • Email Validation <?php $email = “shoro_asif@yahoo.com"; if(filter_var( $email, FILTER_VALIDATE_EMAIL )) { echo "Valid Email"; } else{ echo "invalid Email"; } ?> muhammadabaloch