Esempio n. 1
1
function getProduct($productID, $db_handle)
{
    try {
        $statement_handle = $db_handle->prepare("SELECT * FROM products WHERE productID=(:productID)");
        if (ALL_PRODUCTS == $productID) {
            $statement_handle->bindParam(':productID', ALL_PRODUCTS);
        } else {
            $statement_handle->bindParam(':productID', $productID);
        }
        $statement_handle->execute();
    } catch (PDOException $e) {
        clearAndInitErrors();
        addError($e->getMessage());
    }
    $db_handle = null;
    return $statement_handle->fetchAll();
    displayErrors();
}
Esempio n. 2
0
function displayErrors()
{
    $errors = '';
    if (0 == $_SESSION['errors']['count']) {
        return $errors;
    } else {
        if (1 < $_SESSION['errors']['count']) {
            $pluralize = 's';
        } else {
            $pluralize = '';
        }
    }
    $errors .= "<span id='errors'>";
    $errors .= 'There was ' . $_SESSION['errors']['count'] . " error" . $pluralize . ': ';
    $errors .= $_SESSION['errors']['text'];
    $errors .= "</span>";
    clearAndInitErrors();
    return $errors;
}
Esempio n. 3
0
<?php

include_once './utility/error.php';
include_once './utility/user.php';
clearAndInitErrors();
if (isset($_POST['username']) && isset($_POST['password'])) {
    if (login($_POST['username'], $_POST['password'])) {
    } else {
        addError('Incorrect username/password combination');
    }
} else {
}
?>
<p>login</p>