Page 278 - Beginning PHP 5.3
P. 278

Part III: Using PHP in Practice





























                        Figure 9-6




                How It Works
                The Web form, registration_multi.html, is largely similar to the previous registration.html
                page. However, this form contains a multi-select list box (favoriteWidgets) and two checkboxes
                with the same name (newsletter). Because these controls are capable of sending multiple values, two
                empty square brackets ([]) are appended to the field names:
                            <label for=”favoriteWidgets”>What are your favorite widgets?</label>
                            <select name=”favoriteWidgets[]” id=”favoriteWidgets” size=”3”
                    multiple=”multiple”>
                              <option value=”superWidget”>The SuperWidget</option>
                              <option value=”megaWidget”>The MegaWidget</option>
                              <option value=”wonderWidget”>The WonderWidget</option>
                            </select>
                            <label for=”newsletterWidgetTimes”>Do you want to receive our
                    ‘Widget Times’ newsletter?</label>
                            <input type=”checkbox” name=”newsletter[]” id=”newsletterWidgetTimes”
                    value=”widgetTimes” />
                            <label for=”newsletterFunWithWidgets”>Do you want to receive our
                    ‘Fun with Widgets’ newsletter?</label>
                            <input type=”checkbox” name=”newsletter[]” id=”newsletterFunWith
                    Widgets” value=”funWithWidgets” />







              240





                                                                                                      9/21/09   7:23:40 PM
          c09.indd   240                                                                              9/21/09   7:23:40 PM
          c09.indd   240
   273   274   275   276   277   278   279   280   281   282   283