I have a query that checks a database for a match against the input of a username and password, the corresponding values of this query would be either 0 (no match) or 1 (a match). This would output in a column (itDoesExist) with one value, either the 1 or the 0.
What I would like to know, is how do I get that value in PHP? I guess I am missing something here and I cant quite seem to figure out what that is.
Here is the code:
$stmt = $link->prepare("
SELECT CASE WHEN
EXISTS (
SELECT 1
FROM user_details
INNER JOIN user_info
ON user_details.id = user_info.id
WHERE user_info.emailContact = ?
AND user_details.password = ?
)
OR EXISTS (
SELECT 1
FROM user_details
INNER JOIN user_business_info
ON user_details.id = user_business_info.id
WHERE user_business_info.emailContact = ?
AND user_details.password = ?
)
THEN 1
ELSE 0
END AS itDoesExist
");
if (!$stmt)
{
$error = "{$link->errno} : {$link->error} (Error Searching For User)";
include "C:/wamp/www/includes/html/main/error.html.php";
exit();
}
if (!$stmt->bind_param("ssss", $username, $password, $username, $password))
{
$error = "{$stmt->errno} : {$stmt->error}";
include "C:/wamp/www/includes/html/main/error.html.php";
exit();
}
if (!$stmt->execute())
{
$error = "{$stmt->errno} : {$stmt->error} (Cant execute?)";
include "C:/wamp/www/includes/html/main/error.html.php";
exit();
}
Thanks in advance for any help or information in this regard!