C - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

C

Description:

S? d?ng d? li?u t? FORM ?php //Handle Input here ... server: ki?m tra n?i dung bi?n. 10. Qu?n l d? li?u nh?p. Ki?m tra d? li?u nh?p: ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 16
Provided by: vanx
Category:
Tags: dung

less

Transcript and Presenter's Notes

Title: C


1
Công ngh? LAMP
  • Chuong 5 Qu?n lý d? li?u nh?p

Ph?m Minh Dung
2
N?i dung
  • Nh?p d? li?u
  • Qu?n lý d? li?u nh?p
  • Bi?u th?c chính quy

3
Nh?p d? li?u
  • lt?php
  • //Handle Input here
  • //Check if submit has a value of "Go" - The
    Validator
  • if (_POST"submit" "Go")
  • //The Processor
  • echo("You wrote "._POST"you_wrote")
  • echo("ltbrgtYou could have done whatever you want
  • with the input instead")
  • exit
  • ?gt
  • lt!-- The Frontend HTML form --gt
  • ltform action"lt?php echo(PHP_SELF) ?gt"
    method"POST" gt
  • ltpgtInput a word ltinput type"text" size"20"
    name"you_wrote"gt
  • ltinput type"submit" name"submit"
    value"Go"gtlt/pgt
  • lt/formgt

4
Nh?p d? li?u
  • Forms attribute
  • action file .php s? nh?n du?c d? li?u
  • method
  • GEThttp//localhost/input.php?you_wrotetesting2
    0this20scriptsubmitGo
  • POSThttp//localhost/input.php

5
N?i dung
  • Nh?p d? li?u
  • Qu?n lý d? li?u nh?p
  • Bi?u th?c chính quy

6
Qu?n lý d? li?u nh?p
  • S? d?ng d? li?u t? FORM
  • lt?php
  • //Handle Input here
  • //Check if submit has a value of "Go" - The
    Validator
  • if (_POST"submit" "Go")
  • //The Processor
  • echo("You wrote "._POST"you_wrote")
  • echo("ltbrgtYou could have done whatever you want
  • with the input instead")
  • exit
  • ?gt
  • lt!-- The Frontend HTML form --gt
  • ltform action"lt?php echo(PHP_SELF) ?gt"
    method"POST" gt
  • ltpgtInput a word ltinput type"text" size"20"
    name"you_wrote"gt
  • ltinput type"submit" name"submit"
    value"Go"gtlt/pgt
  • lt/formgt

7
Qu?n lý d? li?u nh?p
  • Xu?t ra FORM giá tr? m?c d?nh
  • ltform action"lt?php echo(PHP_SELF) ?gt"
    method"POST" gt
  • Name ltinput type"text" size"20"
    name"your_name"
  • value "lt?_POST"your_name"?gt" gt
  • ltinput type"submit" name"submit"
    value"Go"gtlt/pgt
  • lt/formgt
  • ?n giá tr? trong FORM
  • ltform action"lt?php echo(PHP_SELF) ?gt"
    method"POST" gt
  • ltinput type"hidden" size"20" name"your_id"
  • value "lt?_POST"your_id"?gt" gt
  • ltinput type"submit" name"submit"
    value"Go"gtlt/pgt
  • lt/formgt

8
Qu?n lý d? li?u nh?p
  • Giá tr? trong FORM l?y t?/dua vào m?ng
  • ltform action"lt?php echo(PHP_SELF) ?gt"
    method"POST" gt
  • ltselect name"pref_cities" multiple size"3"gt
  • ltoptiongtNagpurlt/optiongt
  • ltoption selectedgtMumbailt/optiongt
  • ltoptiongtBangalorelt/optiongt
  • ltoption selectedgtChennailt/optiongt
  • ltoptiongtKolkattalt/optiongt
  • lt/selectgt
  • ltinput type"submit" name"submit"
    value"Go"gtlt/pgt
  • lt/formgt

9
Qu?n lý d? li?u nh?p
  • Ki?m tra d? li?u nh?p
  • client s? d?ng javascript
  • ltform name"MyForm" action"lt?php echo(PHP_SELF)
    ?gt" method"POST" gt
  • Name ltinput type"text" size"20"
    name"your_name"
  • value "lt?_POST"your_name"?gt" gt
  • ltinput type"button" name"submit" value"Go"
    onclickchecksubmit()gtlt/pgt
  • lt/formgt
  • ltscriptgt
  • function checksubmit()
  • if (document.MyForm.your_name.value"")
  • alert("Please enter your name!")
  • else
  • document.MyForm.submit()
  • lt/scriptgt
  • server ki?m tra n?i dung bi?n

10
Qu?n lý d? li?u nh?p
  • Ki?m tra d? li?u nh?p
  • client s? d?ng javascript
  • server ki?m tra n?i dung bi?n
  • lt?
  • if (_POST"your_name""")
  • echo "Please enter your name!"
  • ?gt
  • ltform name"MyForm" action"lt?php echo(PHP_SELF)
    ?gt" method"POST" gt
  • Name ltinput type"text" size"20"
    name"your_name"
  • value "lt?_POST"your_name"?gt" gt
  • ltinput type"submit" name"submit"
    value"Go"gtlt/pgt
  • lt/formgt

11
N?i dung
  • Nh?p d? li?u
  • Qu?n lý d? li?u nh?p
  • Bi?u th?c chính quy

12
Bi?u th?c chính quy
  • N?i dung
  • "xyz"
  • "abcxyz"
  • T?p h?p
  • "xyz"
  • "0123456789" "0-9"
  • "a-Z" "a-zA-Z"
  • "a-Z '-"
  • "xyz"
  • Thay th?, l?p l?i "", "", "?"
  • "x"
  • "x"
  • "x?"

13
Bi?u th?c chính quy
  • L?p l?i
  • "ab3"
  • "ab3,"
  • "ab3,5"
  • Nhóm
  • "x(yz)"
  • "z(yz)3,5"
  • Ký t? d?c bi?t
  • "." single character.
  • "" beginning of the string
  • "" end of the string

14
Bi?u th?c chính quy
  • Ký t? nguyên g?c \
  • Nhóm ký t?
  • "alnum" "a-zA-Z_0-9"
  • "digit" "0-9"
  • "alpha" "a-zA-Z"

15
Bi?u th?c chính quy
  • int ereg(string pattern, string string , array
    regs)
  • if (ereg("(0-91,2)-(0-91,2)-(0-94)",
    date, regs))
  • echo("regs2.regs1.regs3")
  • else
  • echo("Invalid date format date")
  • array split(string pattern, string string , int
    limit)
  • date "19/Sep/1966 is my date of birth"
  • // Delimiters may be slash, dot, hyphen or space
  • array_date split('/. -', date, 4)
  • echo("Day array_date0 Month array_date1
  • Year array_date2ltbrgt\n")
  • echo(array_date3)
Write a Comment
User Comments (0)
About PowerShow.com