title: Making a Login with PHP
body: <p>I'm trying to make a basic login screen with PHP but when I want to check the password with a foreach loop, It won't work. I made an array to save a few usernames and passwords and want to check it with a foreach loop and if you signed in, you should get a message which shows you if you're signed in or not.
  I think the part that is not working is the foreach loop but in my eyes, it should work.</p>
  
  <p>I hope anybody can help me with this problem. Already thanks for the time.
  PHP:</p>
  
  <pre><code>    //message variable aanmaken
      $message = "";
      $succes = false;
  
  // "Database" met usernames en wachtwoorden
  $Data["Matthijs123"] = "ikwilbinnen";
  $Data["MatthijsHulshof"] = "Eindopdracht123";
  $Data["Login"] = "Password";
  $Data["123"] = "456";
  /*$Data[""] = "";
  $Data[""] = "";
  $Data[""] = "";
  $Data[""] = "";
  $Data[""] = "";
  $Data[""] = "";
  */
  // Check of $_POST minimaal 1 item heeft
  if(count($_POST) &gt;= 1)
  {
      $username = $_POST["username"];
      $password = $_POST["password"];
  
  
  
      // Checken of de opgegeven username en wachtwoord in de $data array zit
      foreach($Data as $index =&gt; $value)
      {
          if($username == $index &amp;&amp; $password == $value)
          {
              //Wachtwoord en username combinatie gevonden!
              $succes = true;
          }
          else
          {
             $succes = false;
          }
      }
      if($succes == true)
      {
          $message = "U bent ingelogd";
      }
      else
      {
          $message = "U wachtwoord en / of gebruikersnaam is fout";
      }
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>        &lt;form action="Login.php" method="post"&gt;
              &lt;table id="login"&gt;
                  &lt;tr&gt;
                      &lt;th colspan="2"&gt;Bergheen&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td colspan="2"&gt;Login om adresgegevens + openingstijden te zien.&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $message; ?&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Username:&lt;/td&gt;
                      &lt;td&gt;&lt;input name="Username" type="text" placeholder="Username"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Password:&lt;/td&gt;
                      &lt;td&gt;&lt;input name="Password" type="password" placeholder="Password"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;button&gt;Login&lt;/button&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form&gt;
  </code></pre>