Forums

PHP

This topic is locked

cookie problem in php_mysql...

Posted 15 Feb 2003 05:59:52
1
has voted
15 Feb 2003 05:59:52 Terry Lau posted:
Hello,
I set a cookie in a php page, here is the code:

<i>&lt;?php
if (isset($HTTP_POST_VARS['Name'])) {
setcookie("Name", $HTTP_POST_VARS['Name'], time()+86400*3);
}
?&gt;</i>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=big5"&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form name="form1" method="post" action="request.php"&gt;
&lt;p&gt;Name:
&lt;input name="Name" type="text" id="Name"&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;input type="submit" name="Submit" value="Submit"&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

And in the request.php page, here is the code:

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=big5"&gt;
&lt;/head&gt;

&lt;body&gt;
HI!! <i>&lt;?php echo $HTTP_COOKIE_VARS['Name']; ?&gt; </i>
&lt;/body&gt;
&lt;/html&gt;

But when I run the page, it shows "HI!! Notice: Undefined index: Name in..."
What's the problem??The cookie doesn't work??How can I solve it?
THANKS!!!

Reply to this topic