Here is a little code I wrote myself:
==============================================
<html>
<head>
<title>Checking...</title>
</head>
<body>
<?php
// Variables and an Array listing the users with posting access.
$Status1 = "Undefined";
$Status2 = "Undefined";
print ("<p>"); //Checking if variables were passed.
print $Uname;
print ("<p>");
print $Pword;
print ("<p>");
$Users = array (
array ( name=>"Matt(Jsut33)",
password=>"matt0014" ),
array ( name=>"DJ(Kali)",
password=>"dj0965" )
);
CheckUsername($Uname, $Status1);
CheckPassword($Pword, $Status2);
print ("<p>"); //Checking if Status 1 & 2 are returned.
print $Status1;
print ("<p>");
print $Status2;
print ("<p>");
if ($Status1 == $Users[0][name] and $Status2 == $Users[0][password])
{
//some type of redirecting code to post.htm or delete.htm
print ("You have entered the correct username and password. Thank you.");
}
elseif ($Status1 == $Users[1][name] and $Status2 == $Users[1][password])
{
//some type of redirecting code to post.htm or delete.htm
print ("You have entered the correct username and password. Thank you.");
}
else
{
print ("Sorry, either the username or password supplied was incorrect or does not exist.");
print ("<p>");
print ("Please click ");
print ("here ");
print ("to try again.");
print ("<p>");
}
//*********************FUNCTIONS**************************************************************
//***************************************************************************************************
//Function to check the UserName.
function CheckUsername($Uname, $Status1)
{
print ("<p>"); //Checking if Uname was passed.
print $Uname;
print ("<p>");
if ($Uname == $Users[0][name])
{
$Status1 = $Users[0][name];
}
elseif ($Uname == $Users[1][name])
{
$Status1 = $Users[1][name];
}
print ("<p>");
print $Status1; //Checking if Status1 changed.
print ("<p>");
return $Status1;
}
//****************************************************************************************************
//Function to check the Password.
function CheckPassword($Pword, $Status2)
{
print ("<p>"); //Checking if Pword was passed.
print $Pword;
print ("<p>");
if ($Uname == $Users[0][password])
{
$Status2 = $Users[0][password];
}
elseif ($Uname == $Users[1][password])
{
$Status2 = $Users[1][password];
}
print ("<p>"); //Checking if Status2 changed.
print $Status2;
print ("<p>");
return $Status2;
}
?>
</body>
</html>
==============================================
When I run it I get this:
==============================================
DJ(Kali)
dj0965
DJ(Kali)
Undefined
dj0965
Undefined
Undefined
Sorry, either the username or password supplied was incorrect or does not exist.
Please click here to try again.
==============================================
Can anyone figure out why it's not recognizing the username and password as one of the correct ones and keeping Status 1 & 2 undefined?
I know I should probably just use a code already out there, but I wanted to try and write my own little snippet. Thanks for any help.