ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] (PHP+IIS+MsSQL±Ð¾Ç²Ä18½g) ªí³æÄæ¦ì¸ê®Æ¨Ï¥Î ¤U½g

[±Ð¾Ç] (PHP+IIS+MsSQL±Ð¾Ç²Ä18½g) ªí³æÄæ¦ì¸ê®Æ¨Ï¥Î ¤U½g

®Ö¨ú«ö¶s¡]Checkbox¡^
®Ö¨ú«ö¶s¡]Checkbox¡^¾A¥Î©ó¦h³Æ¿ï®×µª®×¥B¦h¥¿½Tµª®×¿ï¨úªº³õ¦X¡A¦p¦P½Æ¿ïªº¿ï¾ÜÃD¡A¨Ò¦p¿³½ì¡B¶Ý¦n¡Kµ¥¡G
  1. <input type=¡¨Checkbox¡¨ name=¡¨ÃѧO¦W¡¨ value=¡¨¸ê®Æ­È¡¨>
½Æ»s¥N½X
»P³æ¿ï«ö¶s¬Û¦Pªº¬O¨Ï¥ÎªÌ¥u»ÝÂI¿ïµª®×¡A¤£»Ý­n¶ñ¼g¸ê®Æ¡A©Ò¥H¥²¶·¬°¨C¤@­Ó®Ö¨ú«ö¶s«Ø¥ß¤£¦Pªº¸ê®Æ­È¡A¦Ó¥B¬°¤FÅý¦h­Ó®Ö¨ú«ö¶s¦¨¬°½Æ¿ïªº¸s²Õ¡A¬G¦P¸s²Õ¤ºªº®Ö¨ú«ö¶s¨ä¡uname¡vÄÝ©Ê­È¥²¶·¬°¬Û¦Pªº¡uÃѧO¦W¡v¡C
  1. <html><head>
  2. <title>®Ö¨ú«ö¶s¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. <form action="checkbox_ans.php" method="Post">
  5. ½Ð¿ï¾Ü±z³ßÅwªº¤ôªG:<Br>
  6. <Input type="Checkbox" name="food" value="­»¿¼" Checked>­»¿¼
  7. <Input type="Checkbox" name="food" value="Ä«ªG">Ä«ªG
  8. <Input type="Checkbox" name="food" value="ªÝ¼Ö">ªÝ¼Ö
  9. <Input type="Checkbox" name="food" value="»ñ±ù">»ñ±ù
  10. <Input type="Checkbox" name="food" value="¦è¥Ê">¦è¥Ê
  11. <Br>
  12. <input type="Submit">
  13. </form>
½Æ»s¥N½X
­Y­n±N¬Y­Ó®Ö¨ú«ö¶s¹w³]¬°¤w¿ï¨ú¡A«h¥[¤J¡uChecked¡vÄݩʳ]©w§Y¥i¡C»P³æ¿ï«ö¶s³Ì¤jªº¤£¦P¬O®Ö¨ú«ö¶s¦b¿ï¨ú«á¡A¥i¥H¦AÂI¿ï¤@¦¸®Ö¨ú«ö¶s¨ú®ø¿ï¨ú¡C



·í¦P®ÉÂI¿ï¦h­Ó®Ö¨ú«ö¶s«á¡A¦]¬°¨C­Ó®Ö¨ú«ö¶sªº¦WºÙ³£¬Û¦P¡A¦]¦¹¡A·í¸ê®Æ¶Ç°e«á¡A¨C­Ó³QÂI¿ïªº®Ö¨ú«ö¶s¨ä¸ê®Æ­È¤§¶¡·|¥H¤@­Ó¡u¡A¡v³r¸¹»P¤@­ÓªÅ¥Õ¦r¤¸¹j¶}¡A§Ú­Ì¥i¥H§Q¥Î¡ustr_replace()¡v¨ç¼Æ¥[¥H´À´«¡C
  1. <html><head>
  2. <title>®Ö¨ú«ö¶s¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. <?
  5. $myfood=$_REQUEST["food"];
  6. ?>
  7. ±zªº¿ï¾Ü(´À¥N«e):<?=$myfood?>
  8. <P>
  9. ±zªº¿ï¾Ü(´À¥N«á):<?=str_replace(",",";",$myfood)?>
  10. </body></html>
½Æ»s¥N½X
§AÄF¤H¡I§Ú¤£ºÞ¿ï¨ú´X­Ó¶µ¥Ø¡A¥¦´N¬O¥u·|¥X²{³Ì«á¤@­Ó³Q¿ï¨úªº¶µ¥Ø¡A¨þ¡A±zªº±¡§Î¬O¤£¬O¹³¹Ï5-28¤@¼Ë£«¡I³o¬OPHP¤¤ªº¤@­Ó³´¨À¡A¹³®Ö¨ú¤è¶ô³oºØ¤¸¥ó¡A¥i¥H¤@­ÓÃѧO¦WºÙ°O¿ý«Ü¦h¸ê®Æ¤º®eªºª¬ªp¡A§Ú­Ì¥Î¤@­ÓÃѧO¦W¨Ó³B²z·íµM¦æ¤£³q¡I¦]¦¹¡Aªí³æªº®Ö¨ú¤è¶ôÃѧO¦WÀ³¸Ó­n§â¥¦§ï¦¨°}¦C§Î¦¡¡G
  1. <html><head>
  2. <title>®Ö¨ú«ö¶s¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. <form action="checkbox_2_ans.php" method="Post">
  5. ½Ð¿ï¾Ü±z³ßÅwªº¤ôªG:<Br>
  6. <Input type="Checkbox" name="food[]" value="­»¿¼" Checked>­»¿¼
  7. <Input type="Checkbox" name="food[]" value="Ä«ªG">Ä«ªG
  8. <Input type="Checkbox" name="food[]" value="ªÝ¼Ö">ªÝ¼Ö
  9. <Input type="Checkbox" name="food[]" value="»ñ±ù">»ñ±ù
  10. <Input type="Checkbox" name="food[]" value="¦è¥Ê">¦è¥Ê
  11. <Br>
  12. <input type="Submit">
  13. </form>
  14. </body></html>[/code
  15. ]¬JµM®Ö¨ú¶µ¥Ø¤w¸g¦¨¬°°}¦CÅܼƪº¤¸¯À¡A¨º¸Ó¦p¦ó±N¤¸¯À¦C¥X©O¡H·Q°_¨Ó¤F§a¡I´N¬O§Ú­Ì¤w¸g¤¶²Ð¹Lªºfor°j°é£«¡G
  16. [code]<html><head>
  17. <title>®Ö¨ú«ö¶s¤¸¥ó¨Ï¥Î</title>
  18. </head><body>
  19. ±zªº¿ï¾Ü:
  20. <?
  21. $myfood=$_REQUEST["food"];
  22. $num=count($myfood);
  23. for ($x=0; $x<$num; $x++)
  24. {
  25. echo "$myfood[$x] ,";
  26. }
  27. ?>
  28. </body></html>
½Æ»s¥N½X
¤W¨Ò°õ¦æµ²ªG¦p¤U¹Ï¡G




¨Ï¥Îfor±Ô­z¿é¥X°}¦C¤¸¯À¬O°ò¥»¥\¡AÃø´NÃø¦b¦p¦ó¦b¿é¥X®É¬°¨C­Ó°}¦C¤¸¯À¶¡¥[¤J¤À¹j²Å¸¹¡A¹³¹Ï5-29¡A¬O¦b¨C­Ó°}¦C¤¸¯À¶¡¥[¤J³r¸¹¤F¡A¥i¬O¡A³Ì«á¤@­Ó¤¸¯À«á­±«o¦h¤F¤@­Ó³r¸¹¡A³o®É­Ô¡A§Ú­Ì¥i¥H§Q¥Î¡ujoin()¡v¨ç¼Æ¨Ó¸Ñ¨M¡G
  1. <html><head>
  2. <title>®Ö¨ú«ö¶s¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. ±zªº¿ï¾Ü:
  5. <?
  6. $myfood=$_REQUEST["food"];
  7. echo join(",",$myfood);
  8. ?>
  9. </body></html>
½Æ»s¥N½X
join()¨ç¼Æ¤£¶È¥i¦b¤¸¯À¶¡¥[¤J¯S©wªº¦r¦ê¡A¦P®É¤]±N°}¦C¤¤ªº¤¸¯À¤@¤@°µ¿é¥X¡A°£¤Fjoin()¨ç¼Æ¥~¡A¡uimplode()¡v¨ç¼Æ¥ç¦³¬Û¦P¥\¯à¡G
implode()¨ç¼Æ®æ¦¡
  1. string implode ( string glue, array pieces)
½Æ»s¥N½X
¨Ò¦p:
  1. <?
  2. $Myarray = array("¬K¤Ñ","®L¤Ñ","¬î¤Ñ","¥V¤Ñ");
  3. echo implode("<br>",$Myarray);
  4. //¿é¥X'¬K¤Ñ<br>®L¤Ñ<br>¬î¤Ñ<br>¥V¤Ñ'
  5. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

¤U©Ô¦¡¿ï³æ¡]Select¡^
¤U©Ô¦¡¿ï³æ¡]Select¡^¤¸¥ó¨ã¦³³æ¿ï«ö¶sªº¥\¯à¡A¥ç¨ã¦³®Ö¨ú«ö¶sªº½Æ¿ï¥\¯à¡A¤U©Ô¦¡¿ï³æ¤¸¥ó¥Ñ¡u<Select></Select>¡v¼ÐÅÒ©Òºc¦¨¡A¨ä¬°¤@­Ó¶°¦X¶µ¥Ø¤¸¥ó¡A¿ï³æ¤ºªº¨C¤@­Ó³Æ¿ï¶µ¥Ø¥²¶·¦A¨Ï¥Î¡u<Option></Option>¡v¥]¬A°_¨Ó¡G
  1. <Select name=¡¨ÃѧO¦W¡¨>
  2. <Option Value=¡¨¸ê®Æ¤@¡¨>¸ê®Æ¤@</Option>
  3. <Option Value=¡¨¸ê®Æ¤G¡¨>¸ê®Æ¤G</Option>
  4. ¡K
  5. </Select>
½Æ»s¥N½X
­Y¨S¦³¿ï©w¹w³]­È¡A«h¿ï³æ¤ºªº²Ä¤@¶µ¸ê®Æ´N¦¨¬°¹w³]­È¡A­Y±ýóª¨ä¥L¶µ¥Ø¬°¹w³]­È¡A«h¥i¦b<Option>¼ÐÅÒ¤º¥[¤J¡uSelected¡vÄݩʳ]©w¡C
  1. <form action="select_ans.php" method="Post">
  2. ½Ð¿ï¾Ü±z±Mªøªº¹q¸£»y¨¥:<Br>
  3. <Select name="language">
  4. <Option Value="VB">VB</Option>
  5. <Option Value="Delphi" Selected>Delphi</Option>
  6. <Option Value="C++">C++</Option>
  7. <Option Value="PHP">PHP</Option>
  8. <Option Value="Java">Java</Option>
  9. </Select>
  10. <input type="Submit">
  11. </form>
½Æ»s¥N½X
¥Ñ©ó¥Ø«e½d¨Ò¬°³æ¿ï¦¡ªº¤U©Ô¿ï³æ¡A©Ò¥HŪ¨úªºÄæ¦ì¨Ã¤£»Ý­n¯S§O³B²z¡G
  1. <html><head>
  2. <title>¤U©Ô¦¡¿ï³æ¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. <?
  5. $mylanguage=$_REQUEST["language"];
  6. ?>
  7. ±zªº¿ï¾Ü:<?=$mylanguage?>
  8. </body></html>
½Æ»s¥N½X
­Y­n±N¤U©Ô¦¡¿ï³æ³]¬°¦h¶µ¥Ø½Æ¿ï¡A¥i¦b<Select>¼ÐÅÒ¤¤¥[¤J¡umultiple¡vÄݩʳ]©w¡F¹w³]¤U©Ô¿ï³æ¥u·|¥X²{¤@­Ó¸ê®Æ¶µ¥Ø¡]°ª«×¬°1¡^¡A­nÅý¿ï³æ¤¤¥X²{¦h­Ó¸ê®Æ¶µ¥Ø¥i³z¹L¡uSize¡vÄÝ©Ê¥[¥H³]©w¡A¦Ó¥B¤U©Ô¿ï³æ¤¸¥óªºÃѧO¦W¤]À³¸Ó­n§â¥¦§ï¦¨°}¦C§Î¦¡¡G
  1. <form action="select_ans_2.php" method="Post">
  2. ½Ð¿ï¾Ü±z±Mªøªº¹q¸£»y¨¥:<Br>
  3. <Select name="language[]" multiple Size=5>
  4. <Option Value="VB">VB</Option>
  5. <Option Value="Delphi">Delphi</Option>
  6. <Option Value="C++">C++</Option>
  7. <Option Value="PHP">PHP</Option>
  8. <Option Value="Java">Java</Option>
  9. </Select>
  10. <input type="Submit">
  11. </form>
½Æ»s¥N½X
·í¦P®É¿ï¨ú¦h­Ó¸ê®Æ¶µ¥Ø®É¡A¨C­Ó¸ê®Æ¶µ¥Ø¦p¦P®Ö¨ú«ö¶s¤@¯ë¡G³£¬O°}¦C¤¸¯À¡A§Ú­Ì¥i¥H§Q¥Îfor°j°é©Î¡ujoin()¡v¨ç¼Æ¡B¡uimplode()¡v¨ç¼Æ¨Ó¦CÁ|¶µ¥Ø¸ê®Æ¡G
¦b¤U¦C½d¨Ò¤¤¤À§O¨Ï¥Î¡ujoin()¡v¨ç¼Æ»P¡uimplode()¡v¨ç¼Æ¨Ó³B²z¸ê®Æ¡G
  1. <html><head>
  2. <title>¤U©Ô¦¡¿ï³æ¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. <?
  5. $mylanguage=$_REQUEST["language"];
  6. ?>
  7. ±zªº¿ï¾Ü(implode()¨ç¼Æ):<Br>
  8. <?
  9. echo implode(">>",$mylanguage);
  10. ?>
  11. <P>
  12. ±zªº¿ï¾Ü(join()¨ç¼Æ):<Br>
  13. <?
  14. echo join("-->",$mylanguage);
  15. ?>
  16. </body></html>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

ÁôÂÃÄæ¦ì¡]Hidden¡^
ÁôÂÃÄæ¦ì¡]Hidden¡^ÅU¦W«ä¸q¡A´N¬O¥Î¨Ó¶Ç»¼µ{¦¡¤¤¥²¶·¥Î¨ì¤S¤£§Æ±æ¨Ï¥ÎªÌ¸ê®Æªº¸ê®Æ¡AÁôÂÃÄæ¦ì¨Ã¤£·|¥X²{¦bªí³æ¤¤¡C
  1. <input type=¡¨Hidden¡¨ name=¡¨ÃѧO¦W¡¨ value=¡¨¸ê®Æ­È¡¨>
½Æ»s¥N½X
¦P¼Ëªº¡A­Yªí³æ¨Ï¥Î¤¤§t¦³ÁôÂÃÄæ¦ì¡A«hªí³æ¸ê®Æªº¶Ç»¼¤è¦¡À³±Ä¥Î¡uPost¡v¡AÁקK¨Ï¥Î¡uGet¡vªº¤è¦¡¶Ç»¼ªí³æ¸ê®Æ®É¡AÁôÂÃÄæ¦ìªº¸ê®Æªþ¦bºô§}«á¤è¦ÓÅã¥Ü¦bÂsÄý¾¹ªººô§}¦C¤¤¡C
  1. <html><head>
  2. <title>ÁôÂÃÄæ¦ì¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. <form action="hidden_ans.php" method="Post">
  5. ±zªº©m¦W:<Br>
  6. <Input type="Text" name="Username">
  7. <Input type="Hidden" name="UserIP"
  8. Value="<?=$_SERVER["REMOTE_ADDR"]?>">
  9. <Input type="Submit">
  10. </form>
  11. </body></html>
½Æ»s¥N½X
ÁôÂÃÄæ¦ìªº¸ê®ÆŪ¨ú¥u»Ý¦p³æ¦æ¤å¦rÄæ¦ì³B²z§Y¥i¡G
  1. <html><head>
  2. <title>ÁôÂÃÄæ¦ì¤¸¥ó¨Ï¥Î</title>
  3. </head><body>
  4. <?
  5. $myname=$_REQUEST["Username"];
  6. $myip=$_REQUEST["UserIP"];
  7. ?>
  8. ±zªº©m¦W:<Br>
  9. <?=$myname?>
  10. <P>
  11. ±z¨Ó¦Û(ÁôÂÃÄæ¦ì):<Br>
  12. <?=$myip?>
  13. </body></html>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¹ï¤÷¥À­nª¾®¦¡A·P®¦¡B³ø®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD