Title: HTML, PHP
1HTML, PHP
2HTML
- HyperText Markup Language
- ???????????????????????????????? ?????? ????
??????????? ???????????????????? web browser - ????????????????????????? .htm ???? .html
- ??????????????????????? HTML ????????????
ltHTMLgt ltHEADgt
ltTITLEgt Hello lt/TITLEgt lt/HEADgt
ltBODYgt Whats up lt/BODYgt lt/HTMLgt
3???????????????????
- ??????????????????????
- lta href gt .. lt/agt ????????????? link
- ltimg src ..gt ??????????????????
- ltbrgt ??????????????????????
- lthrgt ?????????????????
- lttablegt ??????????
4HTML FORM
- ????? ????????????????????????????????????????
??????????????????????? ???????? Server
ltFORMgt ltINPUTgt ltINPUTgt lt/FORMgt
5ltinput type text valuetext here
nametextbox size20gt
6ltINPUT TYPE"checkbox" NAME"chk01" VALUE"HTML"
CHECKEDgt????????1
7(No Transcript)
8ltinput typepassword namep1gt
9(No Transcript)
10(No Transcript)
11lttextarea rows4 cols30gtlt/textareagt
12ltINPUT TYPEbutton VALUEButton
NAMEbutton1" SIZE20gt
13(No Transcript)
14(No Transcript)
15PHP
- PHP Hypertext Preprocessor
- ??????????????? server ???????????? ASP
- ??????????????????????????????????????????
(MySQL, Informix, Oracle, Sybase, ..etc) - PHP ???? open source
- PHP ???
- PHP ???????????????????? OS (Windows, Linux,
Unix, etc..) - Web server ?????? PHP (IIS, Apache)
- ??????????????????????????????????? .php
16??????????? PHP
- Syntax ??? PHP ???????????
- lt?php ?????????? PHP ?gt
- lt? ?????????? PHP?gt
- ltscript languagephpgt
- ?????????? PHP
- lt/scriptgt
- lt ?????????? PHP gt
- Comment ?? PHP ????????????? C , Java
17lthtmlgt ltbodygt lt? echo Hello World
?gt lt/bodygt lt/htmlgt
PHP
HTML
lthtmlgt ltbodygt Hello World lt/bodygt lt/htmlgt
18????????????????? PHP
- ?????? PHP ?????????????? ???????????????? ????
- myVariable 5
- txt Hello World
- PHP ???????? script ??????????????????????????????
???????????????????????????????? (int, string,..)
???????????? - ????????
lt? txt Hello World echo txt ?gt
19?????? echo
- ??????????????????????????????????????? browser
- ???????????????
- echo ???????1 ??????????1, ???????2
??????????2, ???????3 ??????????3, - ??????? ?????????????????????? double quote ( )
???? single quote ( ) - ????????????? PHP ???????????????????????? ????
20Operation
- ??????????????????? ?????????????????????????????
. - lt?
- txt1Hello World
- txt2 123
- echo txt1 . . txt2
- ?gt
- ????? arithmetic operation ???????????????????????
??? C, java - , - , , / , , , --, , - ,
, ! , lt
21Condition
- If-else ??????????????????????????? C, Java
-
- if (???????? )
- ???????????????????? 1
- ???????????????????? 2
- ???????????????????? N
- else
- ????????????????? ???1
- ????????????????? ???2
- ????????????????? ???N
-
22?????????????? ??????????????
- lt?
- score 75
- if(score gt 80)
- echo A
- else if(score gt 70)
- echo B
- else if(score gt 60)
- echo C
- else if(score gt 50)
- echo D
- else
- echo F
- ?gt
23HTML PHP
- PHP ????????????????? form ??? HTML ????
?????????????????? ??????????? web page
??????????? score ??????????????? php
PHP
lthtmlgt ltform actiona.php"
method"get"gt score ltinput type"text"
name"score"gt ltinput type"submit"
value"submit"gt lt/formgt lt/htmlgt
24???????????? PHP
- ??????????????????????? ? ?????????????????????
Property????? ?????? - Method ???????????????? ???????????? POST ????
GET - Action ?????????????????????????????????????? ?
????????????????????????? ???????????????????????
??????????????????????????
lt? score _GETscore if(score
gt 80) echo A else if(score gt
70) echo B else if(score gt 60) echo
C else if(score gt 50) echo D
else echo F ?gt
grade.html
lthtmlgt ltform actiona.php"
method"get"gt score ltinput type"text"
name"scoregt ltinput type"submit"
value"submit"gt lt/formgt lt/htmlgt
a.php
25GET ??? POST
- Method ?????? form ??? GET ??? POST
?????????????????????? - GET ??????????????????????????????? URL
???????????????? ?????????????????????????????????
???????????????????????????? ?? URL
?????????????????????? Address Bar ???????????? - POST ??????????????????????????????????????????
?????????? URL ???????????????????????????????????
?????????????????? ??????????????????????
?????????????????????? ???? ?????????????
26????????????????????????? Post
???? Index.html ???????????? post ?????????
showData.php
ltform id"form1" name"form1" method"post"
action"showData.php"gt ???? ltinput
name"txtID" type"text" id"txtID"/gtltpgt ???? -
???????ltinput name"txtName" type"text"
id"txtName" /gtltbr /gt ltinput type"submit"
name"Submit" value"????" /gtlt/pgt lt/formgt
???? showData.php ????????????Post ?????
index.html
lt?php echo "???????????????ltbrgt" echo " ????
". _POSTtxtID echo "ltbrgt" echo "????-???????
". _POSTtxtName ?gt
27????????????????????????? Get
???? Index.html ???????????? get ?????????
showData.php
ltform name"form1" id"form1" method"get"
action"showData.php" gt ???? ltinput
name"txtID" type"text" id"txtID"/gtltpgt ???? -
???????ltinput name"txtName" type"text"
id"txtName" /gtltbr /gt ltinput type"submit"
name"Submit" value"????" /gtlt/pgt lt/formgt
???? showData.php ???????????? Get ?????
index.html
lt?php echo "???????????????ltbrgt" echo " ????
". _GETtxtID echo "ltbrgt" echo "????-???????
". _GETtxtName ?gt
28Exercise 2
- ?????????????????? ex2.html ????????????????
Login ??? Password - ?????? login ??? ect ??? password ??? kmutnb
??????? - ????? Welcome ???????????????? H2 ?? 0000FF
- ???????????? ???????
- ????? Go away hacker!! ???????????????? H1 ??
FF0000