I have following login form pointing to the file '../exe/form-exec.php'.
<form id="loginForm" name="loginForm" method="post" action="../exe/login-exec.php">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="112"><b>Login</b></td>
<td width="188"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</form>
Where login-exec.php should validate where inputs login & password has been field and if NOT return to the form file with $errflag.
File login-exec.php:
//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();
}
And partly is working correctly - it is returning to the form - but no error is displayed. Any suggestion much appreciated.
$errmsg_arrshould be places in login-form.php, should it not?