I may be doing this the hard way so feel free to give your opinion.
I basically have a table with
firstname lastname username ID
I need to be able to have a user imput their lastname and verification#
what I did is send a query to the database for the lastname and the ID#
then I sent a query for the ver# and ID
I compared the ID$'s and if they match then return true...
the problem is if both of the lastname and verification# are not found it returns '' or 0. either way the ID's match and it returns true. I need it to return false if the lastname and verification# are both not found....
here is my code
<start code>
<?php require_once('include/Connections/testDb.php'); ?>
<?php
if(empty($POST["lName"])){
header ("Location: verification.php");
}
if(empty($POST["user"])){
header ("Location: verification.php");
}
else {
$fName = $POST["fName"];
$lName = $POST["lName"];
$user = $_POST["user"];
mysql_select_db($database_testDb, $testDb);
$query_username = "SELECT * FROM users WHERE '$user' = users.username";
$username = mysql_query($query_username, $testDb) or die(mysql_error());
$row_username = mysql_fetch_assoc($username);
$totalRows_username = mysql_num_rows($username);
$query_firstName = "SELECT * FROM users WHERE '$fName' = users.fName";
$firstName = mysql_query($query_firstName, $testDb) or die(mysql_error());
$row_firstName = mysql_fetch_assoc($firstName);
$totalRows_firstName = mysql_num_rows($firstName);
$query_lastName = "SELECT * FROM users WHERE '$lName' = users.lName";
$lastName = mysql_query($query_lastName, $testDb) or die(mysql_error());
$row_lastName = mysql_fetch_assoc($lastName);
$totalRows_lastName = mysql_num_rows($lastName);
$firstname = $row_firstName['fName'];
$fUserID = $row_firstName['ID'];
$lastname = $row_lastName['lName'];
$lUserID = $row_lastName['ID'];
$verification = $row_username['username'];
$First = $row_lastName['fName'];
$vUserID = $row_username['ID'];
if ($lUserID =='') AND ($vUserID == ''){
echo("Your information <br><br>");
echo("First Name:");
echo $row_lastName['fName'];
echo("<br>Last Name:");
echo(" $lName");
echo ("<br>Customer#: $verification <br>cannot be validated.");
echo("<br><br>Go here for email validation [ <a href='mailvalidation.php'>Email Validation</a> ]");
}
if ($lUserID == $vUserID){
echo "Congratulations $First $lastname <br> Customer# $verification. <p>You are verified.</p> ";
echo " <a href=\"http://www.classiccatalog.com\">[Click here to continue shopping]</a> [<a href=\"main.php\">[Main Menu]</a>";
}
else{
echo("Your information <br><br>");
echo("First Name:");
echo $row_lastName['fName'];
echo("<br>Last Name:");
echo(" $lName");
echo ("<br>Customer#: $verification <br>cannot be validated.");
echo("<br><br>Go here for email validation [ <a href='mailvalidation.php'>Email Validation</a> ]");
}
mysql_free_result($username);
mysql_free_result($firstName);
mysql_free_result($lastName);
}
?>
</end code>