Long... I have included everything in an attempt not to leave anything out. I think this book is dated and causing me some issues.
Following is data before and after form data My source Code The php generated source code. Paul Kraus I have made the changes. Here is my output before any form data is sent. Before form data ----- Notice: Undefined index: type_sel in c:\inetpub\wwwroot\testing\cookies.php on line 4 Notice: Undefined index: size_sel in c:\inetpub\wwwroot\testing\cookies.php on line 5 Testing Cookies PHP What font type would you like to use? What font size would you like to use? Your cookies say: font Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 46 type= Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 47 Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 48 >bugger Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 50 $font['type'] = Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 51 $font['size'] = Your form variables say: Notice: Use of undefined constant type_sel - assumed 'type_sel' in c:\inetpub\wwwroot\testing\cookies.php on line 58 Notice: Undefined index: type_sel in c:\inetpub\wwwroot\testing\cookies.php on line 58 Notice: Use of undefined constant size_sel - assumed 'size_sel' in c:\inetpub\wwwroot\testing\cookies.php on line 59 Notice: Undefined index: size_sel in c:\inetpub\wwwroot\testing\cookies.php on line 59 > Notice: Undefined index: 'type_sel' in c:\inetpub\wwwroot\testing\cookies.php on line 61 $_POST['type_sel'] = Notice: Undefined index: 'size_sel' in c:\inetpub\wwwroot\testing\cookies.php on line 62 $_POST['size_sel'] = Last modified: Thu Apr 03 21:58:00 Eastern Standard Time 2003 After Form data --------------- Testing Cookies PHP - Beginning PHP4 Ch8 pg 283 What font type would you like to use? What font size would you like to use? Your cookies say: Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 40 type=> Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 44 $font['type'] = Notice: Undefined variable: font in c:\inetpub\wwwroot\testing\cookies.php on line 45 $font['size'] = Your form variables say: type_sel = sans-serif size_sel = 2 Last modified: Thu Apr 03 21:58:00 Eastern Standard Time 2003 Code ----- <?php //cookies.php if (isset($_POST['type_sel'])) setcookie ("font['type']", $_POST['type_sel'], time()+3600); if (isset($_POST['size_sel'])) setcookie ("font['size']", $_POST['size_sel'], time()+3600); $type = array ("arial", "helvetica", "sans-serif", "courier"); $size = array ("1","2","3","4","5","6","7"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Testing Cookies</title> </head> <body> <h1>Testing Cookies PHP - Beginning PHP4 Ch8 pg 283</h1> <hr> <div align='center'> <form method = post> What font type would you like to use? <select name="type_sel"> <option selected value=''>default</option> <?php foreach ($type as $var) echo ( "<option>$var</option>"); ?> </select> <br><br><br> What font size would you like to use? <select name="size_sel"> <option selected value=''>default</option> <?php foreach ($size as $var) echo ( "<option>$var</option>" ); ?> </select> <br><br><br> <input type=submit> </form> <b>Your cookies say:</b><br> <?php echo ( "<font "); echo ( "type=$font[type]" ); if (isset ($font['type'] )) echo "face={$font['type']} "; if (isset ($font['size'] )) echo "size={$font['size']} "; echo ( ">" ); echo ( "\$font['type'] = {$font['type']}<br>" ); echo ( "\$font['size'] = {$font['size']}<br>" ); echo ( "</font><br>" ); ?> <b>Your form variables say:</b><br> <?php echo ( "<font " ); if (isset( $_POST['type_sel'] )) echo "face=" . $_POST['type_sel'] . " "; if (isset( $_POST['size_sel'] )) echo "size=" . $_POST['size_sel'] . " "; echo ( ">" ); echo "type_sel = {$_POST['type_sel']}<br>"; echo "size_sel = {$_POST['size_sel']}<br>"; echo ( "</font>" ); ?> </div> <address><a href="mailto:[EMAIL PROTECTED]"></a></address> <!-- Created: Thu Apr 03 21:10:49 Eastern Standard Time 2003 --> <!-- hhmts start --> Last modified: Thu Apr 03 21:58:00 Eastern Standard Time 2003 <!-- hhmts end --> </body> </html> Php Generated Source -------------------- <br /> <b>Notice</b>: Undefined index: type_sel in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>4</b><br /> <br /> <b>Notice</b>: Undefined index: size_sel in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>5</b><br /> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Testing Cookies</title> </head> <body> <h1>Testing Cookies PHP</h1> <hr> <div align='center'> <form method = post> What font type would you like to use? <select name="type_sel"> <option selected value=''>default</option> <option>arial</option><option>helvetica</option><option>sans-serif</opti on><option>courier</option> </select> <br><br><br> What font size would you like to use? <select name="size_sel"> <option selected value=''>default</option> <option>1</option><option>2</option><option>3</option><option>4</option> <option>5</option><option>6</option><option>7</option> </select> <br><br><br> <input type=submit> </form> <b>Your cookies say:</b><br> font <br /> <b>Notice</b>: Undefined variable: font in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>46</b><br /> type=<br /> <b>Notice</b>: Undefined variable: font in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>47</b><br /> <br /> <b>Notice</b>: Undefined variable: font in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>48</b><br /> >bugger<br /> <b>Notice</b>: Undefined variable: font in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>50</b><br /> $font['type'] = <br><br /> <b>Notice</b>: Undefined variable: font in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>51</b><br /> $font['size'] = <br></font><br> <b>Your form variables say:</b><br> <font <br /> <b>Notice</b>: Use of undefined constant type_sel - assumed 'type_sel' in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>58</b><br /> <br /> <b>Notice</b>: Undefined index: type_sel in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>58</b><br /> <br /> <b>Notice</b>: Use of undefined constant size_sel - assumed 'size_sel' in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>59</b><br /> <br /> <b>Notice</b>: Undefined index: size_sel in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>59</b><br /> ><br /> <b>Notice</b>: Undefined index: 'type_sel' in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>61</b><br /> $_POST['type_sel'] = <br><br /> <b>Notice</b>: Undefined index: 'size_sel' in <b>c:\inetpub\wwwroot\testing\cookies.php</b> on line <b>62</b><br /> $_POST['size_sel'] = <br></font> </div> <address><a href="mailto:[EMAIL PROTECTED]"></a></address> <!-- Created: Thu Apr 03 21:10:49 Eastern Standard Time 2003 --> <!-- hhmts start --> Last modified: Thu Apr 03 21:58:00 Eastern Standard Time 2003 <!-- hhmts end --> </body> </html> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php