示例#1
0
$success = false;
$dbh = new DBWorker();
$app_id = isset($_GET['app']) ? abs($_GET['app']) : null;
$app = null;
if (isset($app_id)) {
    $app = DBWorker::getRow('SELECT * FROM apps WHERE id = :id', ':id', $app_id);
}
if (isset($_POST['add_app'])) {
    $id = isset($_POST['id']) ? abs($_POST['id']) : -1;
    $app_date = $_POST['app_date'];
    $app_summary = trim($_POST['app_summary']);
    $patient_name = $_POST['patient_name'];
    if (preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $app_date) < 1) {
        $error_msg[] = 'Invalid date';
    }
    if (strlen(trim($patient_name)) < 3) {
        $error_msg[] = 'Client name too short';
    }
    $add_app = 'INSERT INTO apps (app_date, app_summary, patient_name) VALUES (:app_d, :app_sum, :patient)';
    if ($_POST['add_app'] == 'Edit') {
        $add_app = 'UPDATE apps  SET app_date = :app_d, app_summary = :app_sum, patient_name = :patient WHERE id = :id';
    }
    $key_val_pairs = array(':app_d' => strtotime($app_date), ':app_sum' => $app_summary, ':patient' => $patient_name);
    if ($id != -1) {
        $key_val_pairs[':id'] = $id;
    }
    if (empty($error_msg)) {
        $dbh->insertMany($add_app, $key_val_pairs);
        $success = true;
    }
}
示例#2
0
 * Date: 8/14/15
 * Time: 6:39 PM
 * To change this template use File | Settings | File Templates.
 */
require_once "auth.inc.php";
require_once "includes/database/DBWorker.php";
$success = null;
if (!empty($_POST['login'])) {
    $user_name = !empty($_POST['username']) ? trim($_POST['username']) : '';
    $name = !empty($_POST['name']) ? trim($_POST['name']) : '';
    $password = !empty($_POST['password']) ? $_POST['password'] : '';
    $email = !empty($_POST['email']) ? $_POST['email'] : '';
    $password = !empty($_POST['password']) ? $_POST['password'] : '';
    $db = new DBWorker();
    $vars = array(':username' => $user_name, ':password' => md5($password), ':email' => $email, ':name' => $name);
    $db->insertMany('INSERT INTO users (username, password, email, name) VALUES (:username, :password, :email, :name)', $vars);
    $success = true;
}
?>
<!doctype html>
<html>
<head>
    <link rel="stylesheet" href="css/header.css" type="text/css"/>
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
    <link rel="stylesheet" href="css/bootstrap-theme.min.css" type="text/css"/>
    <style type="text/css">
        .container {
            width: 400px;
            margin: auto;
            margin-top: 10px;
        }