開発環境
- OS X Lion - Apple(OS)
- Apache (Web Server)
- PHP (サーバーサイドプログラミング言語)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
『初めてのPHP5』 (David Sklar 著、 桑村 潤 翻訳、 廣川 類 翻訳、 オライリー・ジャパン、2005年、ISBN978-4-87311-257-2)の6章(Webフォームの作成)6.7(演習問題)1を解いてみる。
1.
$_POST['noodle']はbarbecued pork、$_POST['sweet'][0]はpuff、$_POST['sweet'][1]はricemeat、$_POST['sweet_q']は4、$_POST['submit']はOrderとなる。
確認。
コード(TextWrangler)
<form method="POST" action="sample20.php"> Braised Noddles with: <select name="noodle"> <option>crab meat</option> <option>mushroom</option> <option>barbecued pork</option> <option>shredded ginger and green onion</option> </select><br /> Sweet: <select name="sweet[]" multiple> <option value="puff"> Sesame Seed Puff <option value="square"> Coconut Milk Gelatin Square <option value="cake"> Brown Sugar Cake <option value="ricemeat"> Sweet Rice and Meat </select> <br /> Sweet Quantity: <input type+"text" name="sweet_q"> <br /> <input type="submit" name="submit" value="Order"> </form> <?php if($_POST){ var_dump($_POST); } ?>
HTMLソース
<form method="POST" action="sample20.php"> Braised Noddles with: <select name="noodle"> <option>crab meat</option> <option>mushroom</option> <option>barbecued pork</option> <option>shredded ginger and green onion</option> </select><br /> Sweet: <select name="sweet[]" multiple> <option value="puff"> Sesame Seed Puff <option value="square"> Coconut Milk Gelatin Square <option value="cake"> Brown Sugar Cake <option value="ricemeat"> Sweet Rice and Meat </select> <br /> Sweet Quantity: <input type+"text" name="sweet_q"> <br /> <input type="submit" name="submit" value="Order"> </form> array(4) { ["noodle"]=> string(14) "barbecued pork" ["sweet"]=> array(2) { [0]=> string(4) "puff" [1]=> string(8) "ricemeat" } ["sweet_q"]=> string(1) "4" ["submit"]=> string(5) "Order" }
0 コメント:
コメントを投稿