I am trying to verify whether the method in my class is returning a true value. Please look at my object below the class and tell me if it is a valid statement. I am using this to verify whether an email address already exists in the database.
My class and it's constructor
class CheckEmail {
public function __construct($email) {
$db = Database::GetHandler();
$sql = "SELECT email from users WHERE email='$email'";
$stmt = $db->prepare($sql);
$stmt->execute();
$rows = $stmt->rowCount();
if($rows > 0) {
return true;
} else {
return false;
}
}
}
My object from this class:
if($checkEmail = new CheckEmail($_POST[email])==true) {...