â» æã£åãæ©ãPHPãç¿å¾ãããæ¹ã¸
ããã³ã¢ã¹æ¬ãã¨ãã¦æåãªæ¬ããå§ããã¾ãï¼
赤ã®ãã³ã¢ã¹æ¬ – PHP4å¾¹åºæ»ç¥
éã®ãã³ã¢ã¹æ¬ – PHP4å¾¹åºæ»ç¥ å®æ¦ç·¨
=======================
å®è·µ! PHPè¬åº§ã第ï¼å·
=======================
ãããã§ãããå®è·µ! PHPè¬åº§ã第5åãå§ãã¾ãã
ä»åããããã¯ãã³ãã¼ã®å
¬éãææ°ã®ã¿ã«ãã¾ããã
ããããçç±ã¯ããã¾ããã1çªã®çç±ã¯èªè
æ°ãææ¡ããããã§ãã
ãã¦ãååã¯Webã¢ããªãä½æããä¸ã§ã®æåã®æ±ãã«ã¤ãã¦èª¬æãã¾ããã
ããã ãã®ãã¨ã«ãã£ãããã¦ãã¦ããããã®ã§ãã
ãããããã©ã¼ã é¢é£ã«ã¯ã¾ã ã¾ã ãã¦ãã¦ãå¿
è¦ã§ãã
åºç¤æè¡ãªãã«éçºããã¨ãå¾ã§ã¯ã¬ã¼ã å¦çã§ãã¨ã©ã¤ç®ã«ããã¾ãã
ããã§ã¯ãä»åãå·éã«å§ãã¾ãããï¼
————————————————–
ãã©ã¼ã æ»ç¥ã?ãªãã¼ã対çç·¨?
VBãªã©ã®ã¢ããªã±ã¼ã·ã§ã³ã¨ãWebã¢ããªã±ã¼ã·ã§ã³ã§ã¯ãæä½æ§ã«å¤§ããª
éããããã¾ãã
ç¹ã«Webã¢ããªã±ã¼ã·ã§ã³ã®æä½æ§ã¯ãã©ã¦ã¶ã«ä¾åãã¦ãã¾ãã®ã§ã使ã
ã«ããã¨è¨ãããå ´åãããã¾ãã
ããããç¾å¨ãã£ã¨ãå©ç¨ããã¦ããã¢ããªã±ã¼ã·ã§ã³ã¯ãã©ã¦ã¶ã§ãããã
ååãããã¥ã¢ã«ãç¡ãã¦ãã¨ããããã®æä½ã¯ã»ã¨ãã©ã®æ¹ãã§ãã¾ãã
ããããã¢ããªã±ã¼ã·ã§ã³ã®ç«å ´ã§ã¯ãå°ã
å°ã£ããã¨ã«ãªãã¾ãã
ãã©ã¦ã¶ã®æ´æ°ã»æ»ãã»é²ããã¿ã³ãèæ
®ããå¿
è¦ãããã®ã§ãã
ã¾ããåãã¼ã¸ã¯URLã«ããå¥ã
ã«å¼ã³åºããã®ã§ãä¸è²«æ§ã®ããæä½(ãªã³ã©
ã¤ã³æ³¨æãªã©)ã®å ´åã«ã¯ãåå¾ã®é¢ä¿ãç¶æããªãã¦ã¯ãªãã¾ããã
ã¾ãããã°ã¤ã³ç®¡çãªã©ãç¾å¨ã®ç¶æ ãææ¡ãã¦ããå¿ è¦ãåºã¦ãã¾ãã
————————————————–
ãµã³ãã«ããã°ã©ã
ä»åããµã³ãã«ããã°ã©ã ãç¨æããã®ã§ããã¦ã³ãã¼ããã¦ãã ããã
åååæ§ã«è§£åãã移åãã¾ãã
————————————————–
解説
ããã§ã¯ã解説ãã¦è¡ãã¾ãã
ãã©ã¦ã¶ã§ç¢ºèªããªãããã¨ãã£ã¿ã§ããã°ã©ã ã½ã¼ã¹ãè¦ã¦ãã ããã
[Step 1]
URL : http://localhost/akira/02_reload/step_1.php
PHP : C:Inetpubwwwrootakira 2_reloadstep_1.php
ååã® [step_6] ã¨åæ§ã®ç©ã§ãã
ä¸è¦ã¾ã¨ãããã§ãããä¸åº¦éä¿¡ãã¿ã³ãã¯ãªãã¯ãã¦ããã
ãã©ã¦ã¶ã®æ´æ°ãã¿ã³ãã¯ãªãã¯ãã¦ãã ããã
Firefox ã§ã¯ãã®ãããªã¡ãã»ã¼ã¸ã表示ããã¾ãã
ããã¼ã¸ã表示ããã«ã¯ãã©ã¼ã ãã¼ã¿ãå度éä¿¡ããå¿ è¦ãããã¾ããã
IE ãåæ§ã§ãã
å®å®³ãç¡ãã¨è¨ãã°ç¡ãã®ã§ãããã§ããã°è¡¨ç¤ºãããªãã«è¶ãããã¨ã¯ã
ãã¾ããã
ã¾ããä»åã®è¬åº§ã®ç®çã¯ã»ãã·ã§ã³ç®¡çã§ãã®ã§ãå¿
è¦ãªããªãã¦ããã
ã«ãä»ãåããã ããã
[Step 2]
ãªããã®ãããªã¡ãã»ã¼ã¸ã表示ãããã®ããç解ãã¾ãããã
ãã©ã¦ã¶ã®ç«å ´ã§èãã¾ãããã
(1) ãã©ã¦ã¶ã¯ããã®ãã¼ã¸ã¯ãã©ã¼ã ãã¼ã¿ãéä¿¡ããçµæã ã¨è¨æ¶ãã¦
ããã
(2) ãã©ã¦ã¶ã¯ãå½ç¶ãã©ã¼ã ãã¼ã¿ãå度éä¿¡ããªãã¨æ£ããçµæãè¿ã£
ã¦ããªãã¨èããã
ä¸è¨ã®ããã«ããã©ã¦ã¶ã¨ãã¦ã¯æ£ããåä½ã ã¨è¨ãã¾ãã
ããã§ã¯ã次ã®å ´åã¯ã©ãã§ããããï¼
[Step 3]
URL : http://localhost/akira/02_reload/step_3.php
PHP : C:Inetpubwwwrootakira 2_reloadstep_3.php
åæ§ã«ãä¸åº¦éä¿¡ãã¿ã³ãã¯ãªãã¯ãã¦ãããã©ã¦ã¶ã®æ´æ°ãã¿ã³ãã¯ãªã
ã¯ãã¦ãã ãããä»åº¦ã¯ã¡ãã»ã¼ã¸ã表示ããã¾ããã
ãªãã§ããããï¼
å®ã¯ããã©ã¼ã ã®éä¿¡æ¹æ³ã post ãã get ã«å¤æ´ããããã§ãã
ããªã¼ãã ã対ççµãããªã¯ãªã
ã¨ããããã«ã¯ããã¾ããã
get ã¡ã½ããã«ã¯ post ã¡ã½ãããããå¶ç´ãããã¾ãã
ä¸çªå¤§ããªå¶ç´ã¯ãéä¿¡ã§ããæåæ°ãå°ãªãã¨ãããã¨ã§ãã
ããã¹ãããã¯ã¹ãè¤æ°ãã£ããããã¡ã¤ã«ã®ã¢ãããã¼ãããããã¨ãã
ããããå¶éã«ã²ã£ãã£ãã£ã¦ãã¾ãã¾ãã
ã§ãã®ã§ãããã¾ã§ postãã©ã¡ã¼ã¿ã§ã®å¯¾çãå¿ è¦ã§ãã
ä¸è¨ã§ããã©ã¦ã¶ã postãã©ã¡ã¼ã¿ãåéä¿¡ãããã¨ããã¨ãã«ãæå³ããª
ãã¡ãã»ã¼ã¸ã表示ããããã¨ããããã¾ããã
対ç㯅
postãã©ã¡ã¼ã¿ãéä¿¡ããªããã¨ã§ããã©ããã£ã¦ï¼
[Step 4]
ã©ããã£ã¦å¯¾çããã®ãæ¤è¨ãã¾ãããã
æé ã説æãã¾ãã
(1) ãã©ã¦ã¶ãã PHP ã«POSTãã©ã¡ã¼ã¿ãéä¿¡ãããã
(2) PHP ã¯POSTãã©ã¡ã¼ã¿ãIDãã¤ãã¦ã©ããã«ä¿åãã¦ããã
(3) PHP ã¯ãã©ã¦ã¶ã« COOKIE ã¨ãã¦IDã渡ãã
(4) PHP ã¯ãã©ã¦ã¶ã« Location ãããã¼ãéããèªåèªèº«ãå度å¼ã³åºãã
(5) ãã©ã¦ã¶ã¯ Location ãããã¼ã«ãããããCOOKIEãPHPã«æ¸¡ãã
(6) PHPã¯COOKIEã®IDã«ãããä¿åããPOSTãã©ã¡ã¼ã¿ãåãåºãã
(7) PHPã¯åãåºããPOSTãã©ã¡ã¼ã¿ãå
ã«ãã¼ã¸ãåºåããã
ãªãã ããããããã§ããã
ãããç解ãã¦ããã¨ãã¨ãã¨å©ãããã§ãã…
ããããå®è·µè¬åº§ã§ãã®ã§ãèããããå®è·µã§ã!
å®ã¯ããã®æé ã¯ã»ãã·ã§ã³ç®¡çã¨ãã¦PHPã«ã¯æ¨æºã§å«ã¾ãã¦ãã¾ãã
ã¡ãªã¿ã«ãLocation ãããã¼ã®URLã«ãgetãã©ã¡ã¼ã¿ãè¨å®ããã°ãããã
ãã
ã¨ãæã£ãããªããéãã§ããï¼ã©ããã¦ãCOOKIEã使ããªãå ´åã
ãã®æ¹æ³ã使ãã¾ãã
ãã£ã¨ããIDãç®ã«è¦ããã®ã§ãã»ãã¥ãªãã£ã¼ã¯ãã¡ãã¡ã§ããã
[Step 5]
URL : http://localhost/akira/02_reload/step_5.php
PHP : C:Inetpubwwwrootakira 2_reloadstep_5.php
åæ§ã«ãä¸åº¦éä¿¡ãã¿ã³ãã¯ãªãã¯ãã¦ãããã©ã¦ã¶ã®æ´æ°ãã¿ã³ãã¯ãªã
ã¯ãã¦ãã ãããä»åº¦ã¯ã¡ãã»ã¼ã¸ã表示ããã¾ããã
$_POST[‘submit_1’] ããã§ãã¯ãã¦ããã©ã¼ã ãéä¿¡ããããå¤æãã¦ãã¾
ãã
ãããããªãã¨ç¡éã«èªåèªèº«ãå¼ã³åºããã¨ã«ãªãã¾ãã
header(“Location: {$_SERVER[‘PHP_SELF’]}”);ã§èªåèªèº«ããã©ã¦ã¶çµç±ã§
å¼ã³åºãã¦ãã¾ãã
ããããå¤ã®ä¿æãã§ãã¦ãã¾ãããLocation ãããã¼ã§ã¯postãã©ã¡ã¼ã¿
ã渡ããªãã®ã§ãå½ç¶ã¨è¨ãã°å½ç¶ã§ãã
[Step 6]
URL : http://localhost/akira/02_reload/step_6.php
PHP : C:Inetpubwwwrootakira 2_reloadstep_6.php
ã»ãã·ã§ã³ã使ã£ã¦å¤ãä¿æãã¦ãã¾ãã
ã¦ã¼ã¶é¢æ°çµç±ãªã®ã§ã¡ãã£ã¨åããã¥ããããç¥ãã¾ããã
ããã§ããããã®ç°å¢ã§ã¯ã¨ã©ã¼ã表示ããã¾ããã
ã»ãã·ã§ã³ãã¼ã¿ä¿æç¨ã«ä½æãããã©ã«ãã®ã¢ã¯ã»ã¹æ¨©ãããã¾ããã
C:PHPsessiondata ã®ã»ãã¥ãªãã£è¨å®ããã¾ãããã
Evreryoneã«ãã«ã³ã³ããã¼ã«æ¨©éãä¸ãã¾ãã
åæ§ã« C:PHPuploadtemp ãè¨å®ãã¦ããã¾ãã
æ£ããå®è¡ããã¾ããã
ã¤ãã§ã«ãC:PHPsessiondata ã®ä¸ãè¦ã¦ã¿ã¾ãããã
sess_3dc59ea4da3d465ef44d37b767d895c0
ãªã©ã¨ãããã¡ã¤ã«ãåºæ¥ã¦ããã¯ãã§ãã
ããããã»ãã·ã§ã³å¤æ°ã®ä¿åå ´æã§ãã
ããããã®ã¦ã¼ã¶ãã»ãã·ã§ã³ã使ãã«ã¯ããã£ã¹ã¯ã®å®¹éãå¿
è¦ãªãã¨ã
解ãã¾ãã
ããã©ã¯ãã©ã¦ã¶ã§COOKIEãè¦ã¦ã¿ã¾ãããã
Firefoxã§ã¯ã
ããã¼ã«ãããªãã·ã§ã³ãããã©ã¤ãã·ã¼ããCOOKIEããCOOKIEã表示ã
ãã¶ãã®ãã·ã³åã®å
容ãè¦ãã¨ãæå·åãã¦æ ¼ç´ããã¦ãã¾ãã
ã§ãã¦ã¿ãã°ãæå¤ã¨ç°¡åã§ããï¼
ãããããã®è£ã®çå±ãç解ãã¦ããã®ãããã§ãããã
次ã¯ããã©ã¼ã æ»ç¥ ?ãã¡ã¤ã«ã¢ãããã¼ãç·¨?ããè¨ç»ãã¦ãã¾ãã
— ä»åã®ã¾ã¨ã ———————————-
ã»ãªãã¼ã対çã«ã¯ãã©ã¡ã¼ã¿ãä¿åããå¿
è¦ãããã
ã»PHPã§ã¯ã»ãã·ã§ã
³ç®¡çã使ããã
ã»ã»ãã·ã§ã³ç®¡çã®å®æ
ã¯IDãã¤ãããã¡ã¤ã«ã¨COOKIEã
————————————————–
ããã§ã¯å®¿é¡ã§ããããªãèªèº«ã®ããã«ã
ã»ãã·ã§ã³é¢é£ããPHPããã¥ã¢ã«ã§èª¿ã¹ã¦ãã ããã
ãã®è¬åº§ã®ç®çã¯çå¾ãä½ããã¨ã§ã¯ãªããããªãèªèº«ã®åãã¤ãããã¨ã§ãã
ã¼ã¡ã¼ã¡ã¨ï¼
— ä»åã®Tips ————————————
ã»ãã·ã§ã³ç®¡çã®çå±ãããã£ã¦ããã°ãèªä½ãããã¨ãå¯è½ã§ãã
äºå®ãPerlè¨èªã§ã»ãã·ã§ã³ç®¡çãå®ç¾ããã©ã¤ãã©ãªãããã¾ãã
Javaè¨èªã§ãã¯ã©ã¹ã§å®ç¾ãã¦ãã¾ãã
PHPã§ãCOOKIEããã³ãã©ãªãã¡ã¤ã«ã使ãã°èªå®¶è£½ã®ã»ãã·ã§ã³ç®¡çã
å®ç¾ã§ãã¾ãããã¾ããå§ããã¾ãããã
————————————————–