RE: [PHP] Cookies not being read - begging php 4 chapter 8 pg 283

From: Date: Fri, 04 Apr 2003 14:44:23 +0000
Subject: RE: [PHP] Cookies not being read - begging php 4 chapter 8 pg 283
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142342@lists.php.net to get a copy of this message
Also when I first run this at the top I get this error... Notice: Undefined index: typeset 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 I assume its because the var have not been filled but I still need the lines there do I need to turn of warnings or something? Paul -----Original Message----- From: Paul Kraus [mailto:pkraus@pelsupply.com] Sent: Friday, April 04, 2003 9:42 AM To: php-general@lists.php.net Subject: [PHP] Cookies not being read - begging php 4 chapter 8 pg 283 I am working through the beginning php 4 book by wrox and I can not get the example to work. It is reading and passing the form data but the cookies is not being written or read here is my code. Also why can I not place these variables in line with the echo statement. If I do it doesn't work. I thought I could just echo "face=$_POST['type_sel'] " <- but it does not work. if ( $_POST['type_sel'] ) echo "face=" . $_POST['type_sel'] . " "; if ( $_POST['size_sel'] ) echo "size=" . $_POST['size_sel'] . " "; Paul Kraus Code ---- <?php //cookies.php if ($_POST['type_sel']) setcookie ("font['type']", $_POST['type_sel'], time()+3600); if ($_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</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 ( $font['type'] ) echo "face=$font['type'] "; if ( $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 ( $_POST['type_sel'] ) echo "face=" . $_POST['type_sel'] . " "; if ( $_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:pdk@PKRAUS"></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

« previous php.general (#142342) next »