I'm new at PHP and although i found similar solutions for this error, i cannot solve it yet. When running this page i get the error: Notice: Undefined index: NameFilledIn in C:\xampp\htdocs\vdab\cookies.php on line 9. When I fill in a name and refresh the page, it does work. Once the time of the cookie is passed and I refresh the page, I get the same error as in the beginning.
The complete code is:
<?php
 if (!empty($_POST["txtName"]))
     {
      setcookie("NameFilledIn", $_POST["txtName"],time() + 60);
      $name = $_POST["txtName"];
     }
     else
     {
      $name = $_COOKIE["NameFilledIn"];
     }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org /TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<?php
  if (isset($name))
  {
   print ("Welcom, ") . $name;
  }
?>
  <form action="cookies.php" method="POST">
  Uour name: <input type="text" name="txtName" value="<?php print ($name);?>">
  <input type="submit" value="Send">
  </form>
<br><br>
<a href="cookies.php">Refresh the page</a>
</body>
</html>
 
    