PHP Login form validation failed
<p>I have following login form pointing to the file '../exe/form-exec.php'.</p>

<pre><code>&lt;form id="loginForm" name="loginForm" method="post" action="../exe/login-exec.php"&gt;
  &lt;table width="300" border="0" align="center" cellpadding="2" cellspacing="0"&gt;
    &lt;tr&gt;
      &lt;td width="112"&gt;&lt;b&gt;Login&lt;/b&gt;&lt;/td&gt;
      &lt;td width="188"&gt;&lt;input name="login" type="text" class="textfield" id="login" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;b&gt;Password&lt;/b&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input name="password" type="password" class="textfield" id="password" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="Submit" value="Login" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p>Where login-exec.php should validate where inputs login &amp; password has been field and if NOT return to the form file with <code>$errflag</code>.</p>

<p>File login-exec.php:</p>

<pre><code>//Start session
    session_start();

    //Include database connection details
    require_once('../inc/config.php');

    //Array to store validation errors
    $errmsg_arr = array();

    //Validation error flag
    $errflag = false;



..... 



//Input Validations
    if($login == '') {
        $errmsg_arr[] = 'Login ID missing';
        $errflag = true;
    }
    if($password == '') {
        $errmsg_arr[] = 'Password missing';
        $errflag = true;
    }

    //If there are input validations, redirect back to the login form
    if($errflag) {
        $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        session_write_close();
        header("location: ../form/login-form.php");
            exit();
}
</code></pre>

<p><strong>And partly is working correctly - it is returning to the form - but no error is displayed.
Any suggestion much appreciated.</strong> </p>
