ãå¦ä¹ æè®°ãsessionæºå¶å®ç°PHPè´ç©è½¦
使ç??å??sessionç??¡µ??¢å¿ ??¡»??¦æsessionå¯å??å½æ??session_start();æ¸ ç©ºç³»ç»ä¸sessionå¯ä»¥ç??session_destroy();å½æ??ã
å??php.iniæ件ä¸å ³äºsessionç?? ç½®ï¼session.save_pathå®ä¹äºåæ¾session ç????¯å¾ï¼session.nameå®ä¹äºsessionIDçåç????ã
ä¸??¢æ¯ç»ä¹ çä¾åï¼ååºä»£ç ã
index.html??¡µ??¢ï¼
åååç??»å??¡?? ??¿å??å??æ
åå ¬ç??å
ç?? å¯??£
æ¥ç??´ç©??½¦
æ件a.php??¡µ??¢ä»£ç ï¼
??´ç©??¡ ??¯????æ©åå
æ件b.php??¡µ??¢ä»£ç ï¼
??´ç©??¡ ??¯????æ©åå
æ件c.php??¡µ??¢ä»£ç ï¼
??´ç©??¡ ??¯????æ©åå
index.phpæ??æ®å??ç??¡µ??¢ï¼
$value) statement */ if(isset($_POST['d'])){ //æ¯å¦ä»??´ç©??½¦ç®¡çç??¢æäº?訨¿æ¥ç foreach($_POST['d'] as $c){ //å¦ææ¯ï¼åå??æäº?訨¿æ¥çåååºå??ä»??´ç©??½¦æ??ç»ä¸å ???? unset($_SESSION['cart'][$c]); } }?>??¿å??å??æ
åå ¬ç??å
ç?? å¯??£
æ¥ç??´ç©??½¦
??´ç©??½¦ç®¡ç??¡µ??¢cart.phpï¼??¿??主??¦å®ç??å ????ååãæ?訦??´ç©??¡µ??¢ï¼
??¿????¦æ³??æphpä¸form??¡??åä¸enctypeå??æ??ç??®¾ç½®ã
form??¡??åä¸çenctypeå??æ??æå®å??æ??æ®ååå??æå¡å??æ¶æµ????å??使ç??çç¼ç ç??»åã
ä¸??¢æ¯åֵ??¯´æï¼
multipart/form-dataï¼ çªä½æ??æ®??¢«ç¼ç 为ä¸æ¡æ¶æ¯ï¼??¡µä¸çæ¯ä¸ªæ??件对åºæ¶æ¯ä¸çä¸ä¸ª????åï¼ä¸å¯¹å符ç¼ç ãå½ä½¿ç??ææ件ä¸ä¼ æ??件ç??¡??åæ¶ï¼??¯¥ֵæ¯å¿
??çãã
application/x-www-form-urlencodedï¼ çªä½æ??æ®??¢«ç¼ç 为åç????/ֵ对ã??¿æ¯æ åçç¼ç ??å¼ãå??å??å对ææå符??¿??¡ç¼ç ï¼??»??®??ï¼ã
text/plainï¼ çªä½æ??æ®ä»¥çº¯ææ¬å½¢å¼??¿??¡ç¼ç ï¼å
¶ä¸ä¸å«ä»»ä½æ??件æ??å¼å符ãå??空????½¬æ¢ä¸º "+" 符å??ï¼ä½ä¸ç¼ç ç¹æ®å符ãæå
å¯????æ??æ®å½¢å¼ã
??¯´æï¼
1ï¼å¦æ??¡??åä¸ææ件??¦ä¸ä¼ ï¼??¡??åä¸formæ ç¾å¿ ??¡»??®¾ç½®enctype="multipart/form-data"æ¥ç¡®ä¿å¿åä¸ä¼ æ件çMIMEç¼ç ã??»??®??æ åµä¸ï¼??¡??åçç¼ç ??å¼æ¯ application/x-www-form-urlencodedï¼ä¸??½ç??äºæ件ä¸ä¼ ï¼
2ï¼??¿??¡sessionå??çæ¶ï¼å¦æå????¡??å??®¾ç½®enctype="text/plain"ï¼å????¿$_POST,$_GET,$_REQUESTçæ¯æ æ³åå??ֵçã??¿ç¹ä¸å®??¦å??å¿ï¼ï¼ï¼
对äºä¸ç??ç??»åç??¿ä¸æ¥????£??ï¼å®??´??å??å¦ä¸ï¼
enctype defines how the data should be formatted before sending. the two correct formats are application/x-www-form-urlencoded (which essentially sends things as key=valye&anotherkey=anothervalue, with http headers) and multipart/form-data (which splits each key up into a distinct section of data). text/plain means nothing should be done - its behaviour is essentially undefined between browsers, and was only ever used for automated email forms in the days before spam. use application/x-www-form-urlencoded for text forms (or leave this to use the default setting) and multipart/form-data for file attachment uploads
text/plain:
Content-Type: text/plain================================================================================foo=barbaz=The first line.The second line.
application/x-www-form-urlencoded:
Content-Type: application/x-www-form-urlencoded================================================================================foo=bar&baz=The+first+line.%0D%0AThe+second+line.%0D%0Amultipart/form-data:
Content-Type: multipart/form-data; boundary=---------------------------314911788813839================================================================================-----------------------------314911788813839Content-Disposition: form-data; name="foo"bar-----------------------------314911788813839Content-Disposition: form-data; name="baz"The first line.The second line.-----------------------------314911788813839--you can see how the first one is useful for passing values UNCHECKED directly into an email program (e.g. if your form uses a mailto: address, so it uses your visitor's email program to send) but is largely useless for programmatic access to fields. only the bottom 2 examples are valid for actual form-based form data
å£??æï¼æ¬æå 容ç??ç½å??ªå??´¡ç®ï¼çæå½åä½?? ææï¼æ¬ç«ä¸æ¿æ ç¸åºæ³å¾??´£ä»»ãå¦æ??åç??ææ¶å«æ??¢ä¾µæçå 容ï¼??¯????ç³»admin@php.cnæ ¸å®å??çã
ç¸å ³æç«
ç¸å ³??????¢
上一篇: 02-CSS整理_html/css_WEB-ITnose
下一篇: Cocos2d-x文件操作