1. <?php // Script 9.1 - customize.php
2.
3. // Handle the form if it has been submitted:
4. if (isset($_POST['submitted'])) {
5.
6. // Send the cookies:
7. setcookie('font_size', $_POST['font_size']);
8. setcookie('font_color', $_POST['font_color']);
9.
10. // Message to be printed later:
11. $msg = '<p>Your settings have been entered! Click <a href="view_settings.php">here</a> to see them in action.</p>';
12.
13. } // End of submitted IF.
14. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
15. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
16. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
17. <head>
18. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
19. <title>Customize Your Settings</title>
20. </head>
21. <body>
22. <?php // If the cookies were sent, print a message.
23. if (isset($msg)) {
24. print $msg;
25. }
26. ?>
27.
28. <p>Use this form to set your preferences:</p>
29.
30. <form action="customize.php" method="post">
31. <select name="font_size">
32. <option value="">Font Size</option>
33. <option value="xx-small">xx-small</option>
34. <option value="x-small">x-small</option>
35. <option value="small">small</option>
36. <option value="medium">medium</option>
37. <option value="large">large</option>
38. <option value="x-large">x-large</option>
39. <option value="xx-large">xx-large</option>
40. </select>
41. <select name="font_color">
42. <option value="">Font Color</option>
43. <option value="999">Gray</option>
44. <option value="0c0">Green</option>
45. <option value="00f">Blue</option>
46. <option value="c00">Red</option>
47. <option value="000">Black</option>
48. </select>
49. <input type="submit" name="submit" value="Set My Preferences" />
50. <input type="hidden" name="submitted" value="true" />
51. </form>
52.
53. </body>
54. </html>