Title: Introduction to PHP part3
1Introduction to PHP part3
2Outline
3????
- ??????????????????????, ??????????
- Ex Google????
- ????????????????????????
- ??HTML??????????
- ??(Form)
- Web server????????????????????????, ????????
4PHP?????
- ?????????????,?????????????????????PHP??????,?????
PHP????????
?????????????PHP?????
User input data
??????????????
PHP??
5??(Form)
- ????????, ??????????????
- ????(Text), ????(Password), ?????(Radio),
?????(Check Box), ???????????(Text Area) - ???????????????????web server
- ?????????????????????
6??(Form)
- ????????GET?POST
- GET?????255 ,?????????????1?????2??http//ip/
get.php?a1b2 - POST????????,????????(????php????????)
???????php
php???ip
??????server?, ???php?????????
?????GET?POST??????
7PHP?? (GET Method)
- ?????????
- ?server????person.html, ????????
ltform method"get" action"get.php"
name"myform"gt ?? ltinput name"name"gtltbrgt ???????
nbspltinput name"check" type"checkbox"gt ??nbsp
ltselect name"year"gt ltoption
value"first"gt??lt/optiongt ltoption
value"second"gt??lt/optiongt ltoption
value"third"gt??lt/optiongt ltoption
value"fourth"gt??lt/optiongt lt/selectgt ? ltinput
name"sex" value"boy" type"radio"gt ? ltinput
name"sex" value"girl" type"radio"gtltbrgt ltinput
name"submit" value"submit" type"submit"gtltbrgt lt/
formgt
??????????GET, ?????server?, server??????get.php,
??, ????????get.php?? (?????person.html?get.php???
?????)
???html???
8??GET????, ???????????????????
??submit?, ???????server
???????get.php?????????????
9get.php????
lt?php name_GET'name' sex_GET'sex'
check_GET'check' year_GET'year' ech
o name echo "???sexltbrgt" if
(strcmp("on",check)0) echo "???? year
year" else echo "??????" ?gt
??_GET?????????????
- ????
- ?????form????name??????????
- echo???????client
- strcmp???????????????function, ?????0
10PHP?? (POST Method)
- ?????
- ?server????message.html, ????????
message.html????
ltform method"post" action"message.php"
name"form"gt ???? ???? ltinput name"name"gtltbrgt ??lt
brgt lttextarea cols"30" rows"5"
name"message"gtlt/textareagtltbrgt lt/formgt
11- ????
- ??POST method??????????????
- ??????nameJohn
- messageHello
12message.php????
lt?php nickname_POST'name' message_POST
'message' timedate("Y-m-d His") echo
"lttable border\"1\"" echo "cellpadding\"2\"
cellspacing\"2\"gt lttbodygt lttrgt" echo
"lttd gt nickname lt/tdgt" echo "lttd gt time
lt/tdgtlt/trgtlttrgt" echo "lttd colspan\"2\"
rowspan\"1\"gt" echo "message
lt/tdgtlt/trgtlt/tbodygtlt/tablegt" ?gt
- ????
- ??_POST?????POST???????
- date(Y-m-d His)????????????
- ?????????, echo ????HTML??
13Outline
14?????
- ?????????????
- ???????????????
- ?????????????
- ???????????????
- ???????????
- ???????????????, ????????????, ????????????
- ?????????????????
15??????????????
?????
????, ??, ??
???????
???
???????
16??????
- ??????????????
- ?????????????, ????????, ?????????????
- ?????????????, ??????
?????
?????
?? ?? ?? ?? ??
1 ?? ??????? 02-2222
2 ?? ?????? 04-1111
3 ?? ?????? 03-5555
?? ?? ?? ?? ?? ????
1 11/23 3 ?
2 11/24 1 ?
17??????
- ????????????, ?????????, ??DDL
- ????????
18?????????? (cont)
- ????(primary key)????(foreigner key)???????????
- ??(primary key) ????????????????, ??????????
- ????????????
- ????????, ?????????
- ????????????,???????????
-
?? ?? ?? ?? ??
1 ?? ??????? 02-2222
2 ?? ?????? 04-1111
3 ?? ?????? 03-5555
??
19??????????
- ???(foreigner key) ?????????????????????
- ??????????????
-
?????
?????
?? ?? ?? ?? ??
1 ?? ??????? 02-2222
2 ?? ?????? 04-1111
3 ?? ?????? 03-5555
?? ?? ?? ?? ?? ????
1 11/23 3 ?
2 11/24 1 ?
????????
???, ???????????
????????
20MySQL
- PHP??????????????, ??PHPMySQL???????
- MySQL?????????????, ?????????
- phpMyAdmin????php3??,??MySQL??????Web?????????????
?????,??MySQL?????????????,??????????????
21??phpMyAdmin?????
- http//ip/home/mysql
- IP?MySQL server?ip address, ????????????, ???PHP
server?IP??
22?????????
???????root, ????, ?????????root???
??????????????
23????????????
- ?????, ?????phpMyAdmin??????????, ?????
- ??Program Files\EasyPHP5.3.0\phpmyadmin??config.in
c.php - ?????cfg'Servers'i'password'
24?????
???????????????
25?????
?????
26????????
???Primary key??????, ??????VarChar, ???????????
27???????
28?????????
?Designer??, ??????????
29????
???????, ??????????????
?????
30????(SQL)
?Access???????
?????????, ??????, ???SQL??
31PHP?????
- ????????????????(?????), ?????php????????????????
- PHP?MySQL??????
????????????
???HTML??
32?? ????
- ?server????bookstore.html???, ??????????
??????php???
???Peh, ????????
33?????
34????
- ????????????????10?
- ??????????????? (???)
- ????????, ???????????, ??????????, ???? (50
bonus)