Seraphino
May 4th, 2006, 06:06 PM
<?
$hostname="<HIDDEN>";
$username="damasterjo";
$password="<HIDDEN>";
$database="damasterjo";
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Customers";
$result=mysql_query($query);
$num=mysql_numrows($result);
//Checks If The Username and Password Exists
//Declaring Variables
$usernameisvalid=0;
$passwordisvalid=0;
$passwordexists=0;
$usernameexists=0;
//loop through all the entrys in the database to see if any match...
while ($usernameisvalid < $num) {
//set the username they want to a variable
$checkuser=$_POST['Username'];
//Set the database user name into a variable
$existing=mysql_result($result,$usernameisvalid,"Username");
//Check whether or not they are the same
if ($checkuser == $existing)
{
$usernameisvalid=$num;
$usernameexists=1;
}
$usernameisvalid++;
}
while ($passwordisvalid < $num) {
//Set Password They Want Into A Variable
$checkpassword=$_POST['Password'];
//Set the database password into a variable
$existingpass=mysql_result($result,$passwordisvalid,"Password");
//Check whether or not they are the same
if ($checkpassword == $existingpass)
{
$passwordisvalid=$num;
$passwordexists=1;
}
$passwordisvalid++;
}
if ($passwordexists == 0 and $usernameexists == 0)
{
echo "This Username or Password is Invalid!";
}
if ($usernameexists == 1 and $passwordexists == 1)
{
echo "This Username and Password Exists!";
}
?>
For some reason, no matter what Username or Password I enter, it keeps saying that it is valid.
Btw, just to let everyone know, this is for a joined project between me and Damasterjo.
$hostname="<HIDDEN>";
$username="damasterjo";
$password="<HIDDEN>";
$database="damasterjo";
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Customers";
$result=mysql_query($query);
$num=mysql_numrows($result);
//Checks If The Username and Password Exists
//Declaring Variables
$usernameisvalid=0;
$passwordisvalid=0;
$passwordexists=0;
$usernameexists=0;
//loop through all the entrys in the database to see if any match...
while ($usernameisvalid < $num) {
//set the username they want to a variable
$checkuser=$_POST['Username'];
//Set the database user name into a variable
$existing=mysql_result($result,$usernameisvalid,"Username");
//Check whether or not they are the same
if ($checkuser == $existing)
{
$usernameisvalid=$num;
$usernameexists=1;
}
$usernameisvalid++;
}
while ($passwordisvalid < $num) {
//Set Password They Want Into A Variable
$checkpassword=$_POST['Password'];
//Set the database password into a variable
$existingpass=mysql_result($result,$passwordisvalid,"Password");
//Check whether or not they are the same
if ($checkpassword == $existingpass)
{
$passwordisvalid=$num;
$passwordexists=1;
}
$passwordisvalid++;
}
if ($passwordexists == 0 and $usernameexists == 0)
{
echo "This Username or Password is Invalid!";
}
if ($usernameexists == 1 and $passwordexists == 1)
{
echo "This Username and Password Exists!";
}
?>
For some reason, no matter what Username or Password I enter, it keeps saying that it is valid.
Btw, just to let everyone know, this is for a joined project between me and Damasterjo.