Hello i'm currently working on a login system, but i'm kinda stuck at the point were the php should check and say were the forms aren't filled in or that the entered value is not correct. It shows that "De gebruikersnaam is niet ingevuld!" But it's not validating if the User exists in the Database.
<?php
if(($_SESSION['sessieinlog']) && ($_SESSION['sessiewachtwoord']))
{
header ("Location: overzicht.php");
}
elseif(($_POST['gebruikersnaam']) && ($_POST['wachtwoord']))
{
$username = mysql_real_escape_string($_POST['gebruikersnaam']);
$password = md5(mysql_real_escape_string($_POST['wachtwoord']));
$checklogin = mysql_query("SELECT * FROM gebruikers WHERE gebruikersnaam = '".$username."' AND wachtwoord = '".$password."'");
if(mysql_num_rows($checklogin) == 1)
{
$row = mysql_fetch_array($checklogin);
$_SESSION['sessieinlog'] = $username;
$_SESSION['sessiewachtwoord'] = 1;
header ("Location: overzicht.php");
}
elseif(mysql_num_rows($checklogin) == 0)
{
//Gebruikersnaam
if(empty($username))
{
print '<p class="form-error">De gebruikersnaam is niet ingevuld!</p>';
}
elseif ($checklogin->gebruikersnaam !== $username)
{
print '<p class="form-error">De gebruikersnaam is niet bekend!</p>'; }
else
{
$gebruikersnaamakkoord = true;
}
//Wachtwoord
if ($gebruikersnaamakkoord == true)
{
if (empty($inwachtwoord))
{
print '<p class="form-error">Het wachtwoord is niet ingevuld!</p>';
}
elseif ($checklogin->wachtwoord !== $password)
{
print '<p class="form-error">Het wachtwoord is niet correct!</p>'; }
}
}
}
else
{
}
?>
Thanks to anybody who will help this beginner, i'm totally new to PHP and would appreciate any kind of help!