On my login page when a user tries to login it takes them to the next page but nothing shows up and on the source code it shows I have some errors that shouldn't be there. It seems it loses the information when it goes to validate the information.
login page
Validation
If you need a live link Here.
test login
Username: test
Password: test
login page
HTML:
<form action="includes/users/validateLogin.php" method="POST">
<table border="0">
<tr>
<td id="user">Username:</td>
<td><input type="text" name="username" size="10" /></td>
</tr>
<tr>
<td id="pass">Password:</td>
<td><input type="password" name="password" size="10" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
Validation
PHP:
$vars = array(
'name'=>$_POST['username'],
'pass'=>$_POST['password']);
$errors = array();
foreach($vars as $values){
if(empty($values)) {
$errors[]="Invalid Value";
}
}
$checkForm = $dbh->prepare("SELECT username,password FROM users WHERE username = :name && password = :pass");
$checkForm->bindValue(":name",
$_POST['username']);
$checkForm->bindValue(":pass",
md5($_POST['password']));
$checkForm->execute();
if($checkForm->rowcount()===0) {$errors[]="Invalid Username or Password";}
if($errors) {userError($errors);}
If you need a live link Here.
test login
Username: test
Password: test