Here is my problem regarding following PHP code....
Why it has wrtten $_COOKIE[font][type=mwadah] ???
Why it has used 2 values as [font] and [type=mwadah]???
Why it has written echo "\$type_sel = $post_type_sel<br>"; without writing echo "$type_sel = $post_type_sel<br>"; ???
I mean why it has put "\" before $type_sel ????
<?php
//cookies.php
if ($_POST[type_sel]) {
setcookie("font[type=mwadah]", $_POST[type_sel], time()+3600);
}
if ($_POST[size_sel]) {
setcookie("font[size]", $_POST[size_sel], time()+3600);
}
//We define some options for font size and typeface, and as it's now safe to
add an HTML header, we do so:
$type = array("arial", "helvetica", "sans-serif", "courier");
$size = array("1","2","3","4","5","6","7");
echo "<html><head><title>Cookie Test</title></head><body><div align='center'>";
//The following form contains a pair of listboxes, which can be used to
specify the user's preferences:
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 "What font size would you like to use?";
echo "<select name='size_sel'>";
echo "<option selected value=''>default</option>";
foreach ($size as $var) {
echo "<option>$var</option>";
}
echo "</select><br><br>";
echo "<input type='submit' value='Get Cookies'>";
echo "</form>";
//Finally, we echo out some useful information, and format it using
appropriate settings:
echo "<b>Your cookies say:</b><br>";
echo "<font ";
if ($_COOKIE[font][type=mwadah]) {
$cookie_font_type = $_COOKIE[font][type=mwadah];
echo "face='$cookie_font_type' ";
}
if ($_COOKIE[font][size]) {
$cookie_font_size = $_COOKIE[font][size];
echo "size='$cookie_font_size' ";
}
echo ">";
echo "\$font[type=mwadah] = $cookie_font_type<br>";
echo "\$font[size] = $cookie_font_size<br>";
echo "</font><br>";
echo "<b>Your form variables say:</b><br>";
echo "<font ";
if ($-POST[type_sel]) {
$post_type_sel = $_POST[type_sel];
echo "face='$post_type_sel' ";
}
if ($_POST[size-sel]) {
$post_size_sel = $_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>";
echo "</div></body></html>";
?>
Why it has wrtten $_COOKIE[font][type=mwadah] ???
Why it has used 2 values as [font] and [type=mwadah]???
Why it has written echo "\$type_sel = $post_type_sel<br>"; without writing echo "$type_sel = $post_type_sel<br>"; ???
I mean why it has put "\" before $type_sel ????
<?php
//cookies.php
if ($_POST[type_sel]) {
setcookie("font[type=mwadah]", $_POST[type_sel], time()+3600);
}
if ($_POST[size_sel]) {
setcookie("font[size]", $_POST[size_sel], time()+3600);
}
//We define some options for font size and typeface, and as it's now safe to
add an HTML header, we do so:
$type = array("arial", "helvetica", "sans-serif", "courier");
$size = array("1","2","3","4","5","6","7");
echo "<html><head><title>Cookie Test</title></head><body><div align='center'>";
//The following form contains a pair of listboxes, which can be used to
specify the user's preferences:
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 "What font size would you like to use?";
echo "<select name='size_sel'>";
echo "<option selected value=''>default</option>";
foreach ($size as $var) {
echo "<option>$var</option>";
}
echo "</select><br><br>";
echo "<input type='submit' value='Get Cookies'>";
echo "</form>";
//Finally, we echo out some useful information, and format it using
appropriate settings:
echo "<b>Your cookies say:</b><br>";
echo "<font ";
if ($_COOKIE[font][type=mwadah]) {
$cookie_font_type = $_COOKIE[font][type=mwadah];
echo "face='$cookie_font_type' ";
}
if ($_COOKIE[font][size]) {
$cookie_font_size = $_COOKIE[font][size];
echo "size='$cookie_font_size' ";
}
echo ">";
echo "\$font[type=mwadah] = $cookie_font_type<br>";
echo "\$font[size] = $cookie_font_size<br>";
echo "</font><br>";
echo "<b>Your form variables say:</b><br>";
echo "<font ";
if ($-POST[type_sel]) {
$post_type_sel = $_POST[type_sel];
echo "face='$post_type_sel' ";
}
if ($_POST[size-sel]) {
$post_size_sel = $_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>";
echo "</div></body></html>";
?>