Ejemplo n.º 1
0
function error_check($post)
{
    if (empty($post['password'])) {
        $error['password'] = "******";
    }
    if (!filter_var($post['email'], FILTER_VALIDATE_EMAIL)) {
        $error['email'] = "Invalid E-Mail Address";
    }
    $sql = "SELECT 1 FROM customers WHERE email = :email";
    $sql_params = array(':email' => $post['email']);
    $results = returnResults($conn, $sql, $sql_params);
    if ($results) {
        $error['dup_account'] = "This username/email account is already registered and in use";
    }
    if ($post['email'] !== $post['confirm_email']) {
        $error['confirm_email'] = "Email entered do not match";
    }
    if ($post['password'] !== $post['confirm_password']) {
        $error['confirm_password'] = "******";
    }
    if (isset($error) && !empty($error)) {
        echo '<Pre>';
        print_r($_SESSION);
        print_r($error);
        exit;
        //header("Location: register.php");
    }
}
Ejemplo n.º 2
0
 // Establish new database connection
 $db = dbConnect('med_timeline', 'tl_ent');
 // Determines if an entry already exists in id_reference
 $idArray = array();
 $tempArray = array();
 foreach ($output as $ingredient) {
     $ingredient['ingredient'] = preg_replace('/ \\(.*\\)/', '', $ingredient['ingredient']);
     array_push($tempArray, $ingredient['ingredient'], $ingredient['strength'], $ingredient['dosage_form']);
 }
 $query = "SELECT DISTINCT id " . "FROM id_reference " . "WHERE id_reference.id In " . "(SELECT id from id_reference where ingredient = ? and " . "strength = ? and dosage_form = ?)";
 for ($i = 1; $i < count($tempArray) / 3; $i++) {
     $query .= "And id_reference.id In " . "(SELECT id from id_reference where ingredient = ? and " . "strength = ? and dosage_form = ?)";
 }
 $statement = $db->prepare($query);
 $statement->execute($tempArray);
 $idArray = returnResults($db, $query, $tempArray);
 // If an entry exists, use the retrieved ID as the reference
 if (count($idArray) > 0) {
     $id = $idArray[0]['id'];
     $query = "INSERT INTO netcare_id (netcare_entry, id)" . "VALUES (?, ?)";
     $statement = $db->prepare($query);
     $statement->execute([$q, $id]);
     // Otherwise, create a new entry
 } else {
     // Insert the netcare_entry in the netcare_id
     $query = "INSERT INTO netcare_id (netcare_entry)" . "VALUES (?)";
     $statement = $db->prepare($query);
     $statement->execute([$q]);
     // Add the id to the netcare_id table
     $id = $db->lastInsertId();
     $query = "UPDATE netcare_id " . "SET id = ? " . "WHERE ai_id = ?";
Ejemplo n.º 3
0
<?php

require_once '../../../../config/db_config.php';
$response = "";
//get the q parameter from URL
$q = $_GET["q"];
// Only run search if $q is not blank
if (strlen($q) > 0) {
    // Adding wildcard markers to query
    $q = "%" . $q . "%";
    // Establish database connection
    $db = dbConnect('abc_dbl', 'abc_vw');
    // Sending prepared statement to server
    $query = "SELECT DISTINCT t1.url , t1.brand_name, t1.strength, " . "t1.route, t1.dosage_form, t1.generic_name " . "FROM price t1 " . "INNER JOIN price t2 " . "ON t1.generic_name = t2.generic_name " . "WHERE ((t2.generic_name LIKE ? OR t2.brand_name LIKE ?) " . "AND t1.unit_price IS NOT NULL)";
    $resultArray = returnResults($db, $query, [$q, $q]);
    // If results were obtained, finish processing
    if (count($resultArray) > 0) {
        // For each group of generic names + strength + route +
        // dosage form, combines the brand names
        $tempArray = array();
        foreach ($resultArray as $key => $item) {
            $tempText = $item['generic_name'] . " (" . $item['strength'] . " " . $item['route'] . " " . $item['dosage_form'] . ")";
            //Cleans up the tempText in case an item was missing
            $tempText = str_replace("  ", " ", $tempText);
            $tempText = str_replace("  ", " ", $tempText);
            $tempText = str_replace("( ", "(", $tempText);
            $tempText = str_replace(" )", ")", $tempText);
            $tempText = str_replace(" ()", "", $tempText);
            if ($key == 0) {
                $tempArray[0] = array('title' => $tempText, 'url' => $item['url'], 'brand_name' => $item['brand_name']);
            } else {
Ejemplo n.º 4
0
            unset($_SESSION['cart'][$pid]);
        } elseif ($qty > 0) {
            $_SESSION['cart'][$pid]['quantity'] = $qty;
        }
    }
}
if (!empty($_SESSION['cart'])) {
    $print_ids = '';
    foreach ($_SESSION['cart'] as $pid => $value) {
        $print_ids .= $pid . ',';
    }
    $print_ids = trim(substr($print_ids, 0, -1));
    $sql = "SELECT prints.*,artists.artists_id,CONCAT_WS(' ', first_name, middle_name, last_name) AS artist FROM prints AS prints\n    JOIN artists ON prints.artist_id = artists.artists_id \n    WHERE prints.print_id IN (" . $print_ids . ") ORDER BY artists.last_name ASC";
    $sql_params = array();
    $conn = connection();
    $results = returnResults($conn, $sql, $sql_params);
    $order_total = 0;
    if (is_array($results)) {
        echo '<form action="view_cart.php" method="post">
                <table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
                    <tr>
                        <td align="left" width="30%"><b>Artist</b></td>
                        <td align="left" width="30%"><b>Print Name</b></td>
                        <td align="right" width="10%"><b>Price</b></td>
                        <td align="center" width="10%"><b>Qty</b></td>
                        <td align="right" width="10%"><b>Total Price</b></td>
                    </tr>';
        foreach ($results as $row) {
            $subtotal = $_SESSION['cart'][$row['print_id']]['quantity'] * $_SESSION['cart'][$row['print_id']]['price'];
            $order_total += $subtotal;
            $_SESSION['order_total'] = $order_total;
Ejemplo n.º 5
0
            if (getenv('HTTP_X_FORWARDED')) {
                $ipaddress = getenv('HTTP_X_FORWARDED');
            } else {
                if (getenv('HTTP_FORWARDED_FOR')) {
                    $ipaddress = getenv('HTTP_FORWARDED_FOR');
                } else {
                    if (getenv('HTTP_FORWARDED')) {
                        $ipaddress = getenv('HTTP_FORWARDED');
                    } else {
                        if (getenv('REMOTE_ADDR')) {
                            $ipaddress = getenv('REMOTE_ADDR');
                        } else {
                            $ipaddress = 'UNKNOWN';
                        }
                    }
                }
            }
        }
    }
    return $ipaddress;
}
if (!mysqli_select_db($conn, "beetle")) {
    include "mysql/createDB.php";
    mysqli_select_db($conn, "beetle");
}
$sql = "SELECT COUNT(*) AS num_tables FROM information_schema.tables WHERE table_schema = 'beetle'";
if (!returnResults($conn, $sql)["num_tables"]) {
    include "mysql/createTables.php";
}
mysqli_query($conn, "SET NAMES utf8");
session_start();
Ejemplo n.º 6
0
/****************************************************************************
 *	UPLOAD DATA TO TABLE													*/
/****************************************************************************
 *	Uploads entry to the netcare_id table									*
 ****************************************************************************/
$parameters = array();
$tempArray = array();
// Determines if an entry already exists in id_reference
for ($i = 0, $count = count($ingredient); $i < $count; $i++) {
    array_push($parameters, $ingredient[$i], $strength[$i]);
}
$query = "SELECT DISTINCT id " . "FROM id_reference " . "WHERE id_reference.id In " . "(SELECT id from id_reference where ingredient = ? and strength = ?)";
for ($i = 2; $i < count($tempArray); $i = $i + 2) {
    $query .= "And id_reference.id In " . "(SELECT id from id_reference where ingredient = ? and strength = ?)";
}
$tempArray = returnResults($db, $query, $parameters);
// If an entry exists, use the retrieved ID as the reference
if (count($tempArray) === 1) {
    $id = $tempArray[0]['id'];
    $parameters = array($netcareEntry[0], $id);
    $query = "INSERT INTO netcare_id (netcare_entry, id)" . "VALUES (?, ?)";
    $statement = $db->prepare($query);
    $statement->execute([$netcareEntry[0], $id]);
    // Otherwise, create a new entry
} else {
    // Insert the netcare_entry in the netcare_id
    $parameters = array($netcareEntry[0]);
    $query = "INSERT INTO netcare_id (netcare_entry)" . "VALUES (?)";
    $statement = $db->prepare($query);
    $statement->execute($parameters);
    // Add the id to the netcare_id table
Ejemplo n.º 7
0
function login($db, $json)
{
    $sql = "select id from User where username = '******'0']}' and password = '******'1']}'";
    returnResults($db, $sql);
}