Hosting your own web site - PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY As

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY As with radio buttons, if no check box is selected, the $_POST[’interests’] element is not even created. So the code for the first check box contains the following: $OK = isset($_POST[’interests’]) ? true : false; This uses the same $OK variable as the radio button group, but that s not a problem, since you ve finished with $_POST[’subscribe’]. So it s safe to reuse $OK. 2. Because the check box array might never be created, you need to set a default value before attempting to build the body of the email. This time, rather than a string, it needs to be presented as an array like this: // set default values for variables that might not exist $subscribe = isset($subscribe) ? $subscribe : ‘Nothing selected’; $interests = isset($interests) ? $interests : array(’None selected’); 3. To extract the values of the check box array, you can use a foreach loop or the implode() function. This oddly named function joins array elements. It takes two arguments: a string to be used as a separator and the array. So, implode(’, ‘, $interests) joins the elements of $interests as a comma-separated string. PHP Solution 5-9: Getting data from a drop-down option menu Drop-down option menus created with the
menus and lists. It s important to use the correct attribute to redisplay the selection if the form is submitted with required items missing. When the page first loads, the $_POST array contains no elements, so you can select the first