title: Cookie newbie php
body: <p>I want to make a contact form that will show the name, gender and comments when I click submit. </p>
  
  <p>Right now I'm not really sure how to retrieve the value from my form and put it in a cookie, so it will dissapear when I refresh.</p>
  
  <p>My code:</p>
  
  <pre><code>  &lt;body&gt; 
  
      $name = $gender = $comment = "";
  
      setcookie("name", $name, time() + 100);
  
      if(isset($_COOKIE["name"]))
      {
          $name = $_COOKIE["name"];
      }
      else
      {
          $name = " ";
      }
  
  
          ?&gt;
  
          &lt;h2&gt;Comment formulier&lt;/h2&gt;
              &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt; 
                 Name: &lt;input type="text" name="name" value="&lt;?php echo $name;?&gt;"&gt;
                 &lt;br&gt;&lt;br&gt;
                 Comment: &lt;textarea name="comment" rows="5" cols="40"&gt;&lt;?php echo $comment;?&gt;&lt;/textarea&gt;
                 &lt;br&gt;&lt;br&gt;
                 Gender:
                 &lt;input type="radio" name="gender" &lt;?php if (isset($gender) &amp;&amp; $gender=="female") echo "checked";?&gt;  value="female"&gt;Female
                 &lt;input type="radio" name="gender" &lt;?php if (isset($gender) &amp;&amp; $gender=="male") echo "checked";?&gt;  value="male"&gt;Male
                 &lt;br&gt;&lt;br&gt;
                 &lt;input type="submit" name="submit" value="Submit"&gt; 
              &lt;/form&gt;
  
          &lt;?php
          echo "&lt;h2&gt;Comments:&lt;/h2&gt;";
          echo $name;
          echo "&lt;br&gt;";
          echo $comment;
          echo "&lt;br&gt;";
          echo $gender;
          ?&gt;
  
          &lt;/body&gt;
  </code></pre>
  
  <p>Please excuse me for this very newbie question, I just started learning PHP 2 weeks ago.</p>