I've typed out the code but get all kinds of errors:
Notice: Undefined variable: size_sel in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 7
What font type would you like to use? DefaultArialHelveticaCourierSans-Serif
Your cookies say:
Notice: Use of undefined constant type - assumed 'type' in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 40
face='Courier'
Notice: Use of undefined constant size - assumed 'size' in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 45
Notice: Undefined index: size in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 45
> $font[type] = Courier
Notice: Undefined index: size in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 52
$font[size] =
Your variables say:
Notice: Undefined variable: size_sel in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 62
> $type_sel =
Notice: Undefined variable: size_sel in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 69
$size_sel =
Anyone got any ideas why? I'm a bit stuck, I don't know how to fix the errors.
Here's my code:
Code:
<?php
if ($type_sel)
{
setcookie ("font[type]", $type_sel, time() + 3600);
}
if ($size_sel)
{
setcookie ("font[size]", $size_sel, time() + 3600);
}
$type = array ("Arial", "Helvetica", "Courier", "Sans-Serif");
$size = array ("1", "2", "3", "4", "5", "6", "7");
echo "<html>";
echo " <head>";
echo " <title>Cookie Test</title>";
echo " </head>";
echo "";
echo " <body>";
echo " <div align='center'>";
echo " <form method='post'>";
echo " What font type would you like to use?";
echo " <select name='type_sel'>";
echo " <option selected value=''>Default</option>";
foreach ($type as $var)
{
echo "<option>$var</option>";
}
echo " </select><br><br>";
echo " <input type='submit'>";
echo " </form>";
echo "";
echo " <b>Your cookies say:</b><br>";
echo " ";
echo " \$font[type] = $font[type]<br>";
echo " \$font[size] = $font[size]<br>";
echo " <br>";
echo " <b>Your variables say:</b><br>";
echo " ";
echo " \$type_sel = $type_sel<br>";
echo " \$size_sel = $size_sel<br>";
echo " <br>";
echo " </div>";
echo " </body>";
echo "</html>";
?>