// Author: Hugh E. Williams, 2001-3
//
// Unless otherwise stated, the source code distributed with this book can be
// redistributed in source or binary form so long as an acknowledgment appears
// in derived source files.
// The citation should list that the code comes from Hugh E. Williams and David
// Lane, "Web Database Application with PHP and MySQL" published by O'Reilly &
// Associates.
//
// This code is under copyright and cannot be included in any other book,
// publication, or educational product without permission from O'Reilly &
// Associates. No warranty is attached; we cannot take responsibility for errors
// or fitness for use.
// This script allows a user to enter their credit card number
// and delivery instructions.
// The user must be logged in to view it.
require_once "../includes/template.inc";
require_once "../includes/winestore.inc";
require_once "../includes/authenticate.inc";
set_error_handler("customHandler");
session_start();
// Check the user is properly logged in
sessionAuthenticate(S_SHOWCART);
// Takes form heading, instructions, action, formVars name, and
// formErrors name as parameters
$template = new winestoreFormTemplate("Finalise Your Order", "Please enter your SurchargeCard details " . "(Try: 8000000000001001 ) and delivery instructions.", S_ORDER_2, "ccFormVars", "ccErrors");
// Create the credit card widgets
$template->mandatoryWidget("creditcard", "SurchargeCard:", 16);
$template->mandatoryWidget("expirydate", "Expiry Date (mm/yy):", 5);
$template->optionalWidget("instructions", "Delivery Instructions:", 128);
$template->showWinestore(SHOW_ALL, B_SHOW_CART | B_HOME);
Example #2
0
        $_SESSION["custFormVars"]["{$variable}"] = $value;
    }
}
// Load the titles from the title table
$titleResult = $connection->query("SELECT * FROM titles");
if (DB::isError($titleResult)) {
    trigger_error($titleResult->getMessage(), E_USER_ERROR);
}
// Load the countries from the country table
$countryResult = $connection->query("SELECT * FROM countries");
if (DB::isError($countryResult)) {
    trigger_error($countryResult->getMessage(), E_USER_ERROR);
}
// Create widgets for each of the customer fields
$template->selectWidget("title_id", "Title:", "title", $titleResult);
$template->mandatoryWidget("firstname", "First name:", 50);
$template->mandatoryWidget("surname", "Surname:", 50);
$template->optionalWidget("initial", "Middle initial:", 1);
$template->mandatoryWidget("address", "Address:", 50);
$template->mandatoryWidget("city", "City:", 50);
$template->optionalWidget("state", "State:", 20);
$template->mandatoryWidget("zipcode", "Zip code:", 10);
$template->selectWidget("country_id", "Country:", "country", $countryResult);
$template->optionalWidget("phone", "Telephone:", 15);
$template->mandatoryWidget("birth_date", "Date of Birth (dd/mm/yyyy):", 10);
// Only show the username/email and password widgets to new users
if (!isset($_SESSION["loginUsername"])) {
    $template->mandatoryWidget("loginUsername", "Email/username:"******"loginPassword", "Password:", 15);
}
// Add buttons and messages, and show the page
Example #3
0
<?php

// Source code example for Web Database Applications with PHP and MySQL, 2nd Edition
// Author: Hugh E. Williams, 2001-3
//
// Unless otherwise stated, the source code distributed with this book can be
// redistributed in source or binary form so long as an acknowledgment appears
// in derived source files.
// The citation should list that the code comes from Hugh E. Williams and David
// Lane, "Web Database Application with PHP and MySQL" published by O'Reilly &
// Associates.
//
// This code is under copyright and cannot be included in any other book,
// publication, or educational product without permission from O'Reilly &
// Associates. No warranty is attached; we cannot take responsibility for errors
// or fitness for use.
// Show the login page
require_once "../includes/template.inc";
require_once "../includes/winestore.inc";
require_once "../includes/validate.inc";
set_error_handler("customHandler");
session_start();
// Takes <form> heading, instructions, action, formVars name, and
// formErrors name as parameters
$template = new winestoreFormTemplate("Login", "Please enter your username and password.", S_LOGINCHECK, "loginFormVars", "loginErrors");
$template->mandatoryWidget("loginUsername", "Username/Email:", 50);
$template->passwordWidget("loginPassword", "Password:", 8);
// Add buttons and messages, and show the page
$template->showWinestore(NO_CART, B_HOME);