Exemplo n.º 1
0
    $dbh = new PDO($db_conn, $db_user, $db_pass, array(PDO::ATTR_PERSISTENT => TRUE, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} catch (PDOException $e) {
    print "Error connecting to database: " . htmlspecialchars($e->getMessage());
    die;
}
header('Content-Type: text/html; charset=UTF-8');
$title = "View user";
$userid = NULL;
if (array_key_exists('userid', $_GET)) {
    $userid = $_GET['userid'];
}
$user = NULL;
$user_data = NULL;
if ($userid !== NULL) {
    try {
        $user = db_Customer::load($dbh, $userid);
        if ($user !== NULL) {
            $title = htmlspecialchars(combine_name($user->first_name, $user->middle_name, $user->last_name));
            $user_data = $user->to_array();
        }
    } catch (PDOException $e) {
        print "Database error: " . htmlspecialchars($e->getMessage());
        die;
    }
}
$labelclass = "formlabel";
$s_title = "{$title} - {$s_organization}";
require 'head.php';
if ($user_data !== NULL) {
    $name = htmlspecialchars(combine_name($user->first_name, $user->middle_name, $user->last_name));
    echo "  <h1>{$name}</h1>";
Exemplo n.º 2
0
 }
 $s_title = "{$title} - {$s_organization}";
 require 'head.php';
 $user = NULL;
 $s_submit = "button.new_customer";
 if ($userid !== NULL) {
     try {
         $user = db_Customer::load($dbh, $userid);
     } catch (PDOException $e) {
         print "Database error: " . htmlspecialchars($e->getMessage());
         die;
     }
     $s_submit = "button.update_customer";
 }
 if ($user === NULL) {
     $user = new db_Customer();
 }
 $s_submit = htmlspecialchars(getlocalstr($s_submit));
 $user_data = $user->to_array();
 echo "   <h1>{$title}</h1>\n";
 echo "   <form method=\"post\" enctype=\"application/x-www-form-urlencoded\" action=\"edit.php\" name=\"editform\">\n    <table class=\"formtable\">\n";
 foreach ($formfields as $field) {
     if (!$is_submit && array_key_exists($field->Name, $user_data)) {
         $field->Value = $user_data[$field->Name];
     }
     $labelclass = 'formlabel';
     if (!$field->IsValid() && $is_submit) {
         $labelclass = 'formerror';
     }
     echo "    <tr>\n";
     if ($field->InputType == 'checkbox' || $field->InputType == 'radio') {