title: Show information only after complete form
body: <p>I have the following code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;?php
          if (!isset($_COOKIE["loggedin"])){
              ?&gt;
              &lt;form action="index.php" method="POST" name="name_form"&gt;
                  Username &lt;input type="text" name="username"&gt;
                  &lt;br/&gt;
                  Password &lt;input type="text" name="password"&gt;
                  &lt;br/&gt;
                  Remember Me &lt;input type ="checkbox" name="remember_me" value="1"&gt;
                  &lt;br/&gt;
                  &lt;input type="submit" name="submit" value="Log in"&gt;
              &lt;/form&gt;
              &lt;?php
                  if(preg_match("/&lt;|&gt;/", $_POST["username"])){    
                      echo "do not log in";
                  } 
                  else if(preg_match("/&lt;|&gt;/", $_POST["password"])){   
                      echo "do not log in";
                  }
                  else {
                      //Open/create passwords.txt
                      $passwordsFile = fopen("passwords.txt", "a");
                      //write users username and password to passwords.txt
                      $text_written = fwrite($passwordsFile, $_POST["username"] . "," . $_POST["password"] . "\r\n");
                      fclose($passwordsFile);
                      setcookie("loggedin", $_POST["username"]);
                      setcookie("loggedintime", time());
                      echo "&lt;h1&gt;Welcome " . $_COOKIE["loggedin"] . "&lt;/h1&gt;";
                      echo "You have been logged in for " . $_COOKIE["loggedintime"] . " seconds.";
                      echo    "&lt;nav&gt;
                                  &lt;ul&gt;
                                      &lt;li&gt;Browse books in store&lt;/li&gt;
                                      &lt;li&gt;Analytics&lt;/li&gt;
                                      &lt;li&gt;Logout&lt;/li&gt;
                                  &lt;/ul&gt;
                              &lt;/nav&gt;";
                  }
          }
      ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>But it's showing the "Welcome ____, you have been logged in for..." part before the user completes the form correctly and I would like to know what to do if I want to show it only after the user complete the form correctly.</p>
  
  <p>Thanks!</p>