title: Php not sending with headers
body: <p>Hello, I am having trouble with some of my code. Even my teacher can't help me, and I don't know where else to go. When my foreach loop is activated and the password and username are the same as the hard-coded strings, it is still redirecting to loginerror.php. When I remove header("Location: loginerror.php"), it functions fine. Why is the last line of my code still activated, when it should load a new page?</p>
  
  <pre><code>&lt;?php session_start(); ?&gt;
  &lt;html&gt;
  &lt;header&gt;&lt;/header&gt;
  &lt;body&gt;
  &lt;form action="login.php" Method="post"&gt;
   Username: &lt;input type="text" name="Username"&gt; &lt;/br&gt;&lt;/br&gt;
   Password: &lt;input type="password" name="Password"&gt; &lt;/br&gt;&lt;/br&gt;
   &lt;input type="submit" value="Login"&gt;&lt;/br&gt;&lt;/br&gt;
   &lt;/form&gt;
  &lt;?php 
  
  
   $username=$_POST["Username"];
   $password=$_POST["Password"];
   if($username == NULL){print("Enter a Username please");}
   else {
  
  
    $users= array
    (
   "Bourne"=&gt;"postcode",
    "Unidan"=&gt;"pincode",
    "yoda"=&gt;"sith"
     );
  
    foreach($users as $user=&gt;$password_value)
    {
    if(($user==$username)&amp;&amp;($password_value==$password))
    {
    $_SESSION['login?']=1;
    header("Location: calculation.php");
    }}
    $_SESSION['login?']=0;
    header("Location: loginerror.php");
    }
  
    ?&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>