when I typed http:/.... index.php and checked a value, the welcome.php should set the cookie of opt_level and
next time when I browse index.php again, the cookie should be showed. but somehow it did not. What is wrong with my code? Thanks.
-----------------index.php----------------
<?php
$_text['low'] = 'Low';
$_text['medium'] = 'Medium';
$_text['submit'] = 'Ok';
echo $_COOKIE["opt_level"] . ";";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html>
<head>
</head>
<body>
<form action="welcome.php" method="post" name="settings">
<label><input type="radio" name="opt_level" value="medium" <?php if ($_COOKI
E['opt_level']=="medium")
{ print "checked "; } ?>/><?= $_text['medium'] ?></label><br />
<label><input type="radio" name="opt_level" value="low" <?php if ($_COOKIE['
opt_level']=="low")
{ print "checked "; } ?>/><?= $_text['low'] ?></label><br />
<input type="submit" name="ok" value="<?= $_text['submit'] ?>" />
</form>
</body>
</html>
</html>
-----------------welcome.php----------------
<?php
setcookie("opt_level",$_POST["opt_level"]);
?>
why the cookie is not set?
Moderator: General Moderators