PHP Classes

Tiny PHP Address Book: Manage address book stored in a database with PDO

Recommend this page to a friend!
  Info   View files Example   View files View files (35)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 242 All time: 8,004 This week: 83Up
Version License PHP version Categories
tiny-address-book 1.0.0BSD License5.4PHP 5, Databases, AJAX
Description 

Author

This package can manage address book stored in a database with PDO.

It can store in a database contact information records with first and last name, street, post code and city.

The package provides a AJAX based user interface to display and edit the contacts in an address book database table.

Innovation Award
PHP Programming Innovation award nominee
March 2017
Number 10
Address books are useful to keep track of user contacts in a database.

This package provides an AJAX based user interface to manage the information of an address book.

Manuel Lemos
Picture of Vallo Reima
  Performance   Level  
Name: Vallo Reima is available for providing paid consulting. Contact Vallo Reima .
Classes: 6 packages by
Country: Estonia Estonia
Age: ???
All time rank: 8333 in Estonia Estonia
Week rank: 312 Up2 in Estonia Estonia Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php

/**
 * the entry
 *
 * @package System
 * @author Vallo Reima
 * @copyright (C)2013
 */
define('SGN', 'aBook'); /* signature */
define('APP', 'abk'); /* application token */
define('DEV', 1); /* development status */

if (version_compare(PHP_VERSION, '5.4', '<')) {
  die(
'System requires PHP 5.4 or newer version');
} else {
 
error_reporting(-1);
 
ini_set('display_errors', true);
 
ini_set('log_errors', false);
}

define('DS', DIRECTORY_SEPARATOR); /* directory separator */
define('PRID', 'pri' . DS); /* system directory */
define('PUBD', 'pub' . DS); /* assets directory */
define('EXT', '.php'); /* default extension */

require_once(PRID . 'startup' . EXT); /* bootstrap */
$application = new Frontal(); /* front controller */
$application->Run(); /* perform action */
?>


Details

Tiny Address Book

This demo application shows the design and programming techniques used in my projects. Some of the components of vRegistry framework are used. All the code is original (except some standard functions).

Functionality

The database consists of contacts and towns tables containing First & Last Name, Street, Postcode and Town data. The records can be added, deleted or modified. The table can be browsed and saved in XML format. Double-clicking on the row selects the record for editing. The towns list must be edited outside.

The demo is uploaded on [arc.vregistry.com].

Design & programming

OOP MVC principles are followed both on the back and front end. The AJAX is used for client-server communications. See [app.vregistry.com] regarding the techniques.

Requirements

  • Webserver: Apache or IIS supporting PHP and MySql
  • PHP: version 5.4+, PDO mysql and sqlite extensions
  • MySql: version 5+, Innodb engine
  • JavaScript: 1.5+ version
  • Browser: any common (IE, FF, Chrome, Safari, Opera,...), newer version

Installation

Unpack the abk.zip to your local/remote webserver retaining the folder structure. Create and load the MySql database from the sql files supplied. Find/change the connection properties in the configuration file /pri/abk/abk.xml (node db):

  • nme - database name
  • usr - access username
  • pwd - access password
  • pfx - database and username prefix (if hosting requires)

File structure

The files are arranged in folders according to their scope and functionality.

Folders

The root folder contains default startup. The folders:

  • pri - private server-side files; subfolders: + abk - application files + sys - framework files + tmp - temporary workfiles
  • pub - public client-side files; subfolders: + js - JavaScript code + css - stylesheets + pic - images
  • dev - miscellaneous development data

The abk and sys folders (may) have the subfolders:

  • _act - actions PHP code *.php
  • _css - dynamic CSS code *.css
  • _js - dynamic JavaScript code *.js
  • _lib - PHP classes *.php
  • _srv - action's PHP services *.inc
  • _tpl - htm templates *.phtml

Files

  • index.php - startup
  • php.php - check PHP version
  • pri/.htaccess - deny access
  • pri/gateway - common data gateway
  • pri/startup - bootstrap
  • dev/abook_data.sql - MySql data loading queries
  • dev/abook_struc.sql - MySql structure queries
  • pri/abk/abk.db - dictionary
  • pri/abk/abk.xml - configuration
  • pri/abk/_act/abook.php - main panel creator
  • pri/abk/_act/browse.php - browse panel creator
  • pri/abk/_act/finish.php - bye panel creator
  • pri/abk/_act/shell.php - layout creator
  • pri/abk/_css/shell.css - layout style
  • pri/abk/_js/abook.js - editor/browser class
  • pri/abk/_lib/Frontal.php - front controller class
  • pri/abk/_srv/abook.inc - data manipulation
  • pri/abk/_srv/browse.inc - browse services
  • pri/abk/_tpl/abook.phtml - panel template
  • pri/abk/_tpl/browse.phtml - browse template
  • pri/abk/_tpl/shell.phtml - layout template
  • pri/sys/_act/download.php - file download dialogue
  • pri/sys/_lib/Base.php - base functionality class
  • pri/sys/_lib/Common.php - common methods & properties class
  • pri/sys/_lib/Database.php - database abstraction layer class
  • pri/sys/_lib/IData.php - database I/O layer interface
  • pri/sys/_lib/Mypdo.php - PDO I/O layer
  • pri/sys/_lib/Texts.php - multilingual texts class
  • pri/sys/_tpl/exit.phtml - finish/error panel template
  • pri/sys/_tpl/exits.phtml - exit panel shell template

ChangeLog

  • Mar 2017 - shell design correction

[app.vregistry.com]: http://app.vregistry.com/hlp/en/spgm [arc.vregistry.com]: http://arc.vregistry.com/abk/


  Files folder image Files  
File Role Description
Files folder imagedev (2 files)
Files folder imagepri (3 files, 2 directories)
Files folder imagepub (3 directories)
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file php.php Aux. Auxiliary script
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  dev  
File Role Description
  Accessible without login Plain text file abook_data.sql Data Auxiliary data
  Accessible without login Plain text file abook_stru.sql Data Auxiliary data

  Files folder image Files  /  pri  
File Role Description
Files folder imageabk (1 file, 6 directories)
Files folder imagesys (3 directories)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Plain text file gateway.php Class Class source
  Accessible without login Plain text file startup.php Aux. Auxiliary script

  Files folder image Files  /  pri  /  abk  
File Role Description
Files folder image_act (4 files)
Files folder image_css (1 file)
Files folder image_js (1 file)
Files folder image_lib (1 file)
Files folder image_srv (2 files)
Files folder image_tpl (3 files)
  Accessible without login Plain text file abk.xml Data Auxiliary data

  Files folder image Files  /  pri  /  abk  /  _act  
File Role Description
  Accessible without login Plain text file abook.php Example Example script
  Accessible without login Plain text file browse.php Example Example script
  Accessible without login Plain text file finish.php Aux. Auxiliary script
  Accessible without login Plain text file shell.php Example Example script

  Files folder image Files  /  pri  /  abk  /  _css  
File Role Description
  Accessible without login Plain text file shell.css Data Auxiliary data

  Files folder image Files  /  pri  /  abk  /  _js  
File Role Description
  Accessible without login Plain text file abook.js Data Auxiliary data

  Files folder image Files  /  pri  /  abk  /  _lib  
File Role Description
  Plain text file Frontal.php Class Class source

  Files folder image Files  /  pri  /  abk  /  _srv  
File Role Description
  Accessible without login Plain text file abook.inc Example Example script
  Accessible without login Plain text file browse.inc Data Auxiliary data

  Files folder image Files  /  pri  /  abk  /  _tpl  
File Role Description
  Accessible without login Plain text file abook.phtml Example Example script
  Accessible without login Plain text file browse.phtml Example Example script
  Accessible without login Plain text file shell.phtml Example Example script

  Files folder image Files  /  pri  /  sys  
File Role Description
Files folder image_act (1 file)
Files folder image_lib (6 files)
Files folder image_tpl (2 files)

  Files folder image Files  /  pri  /  sys  /  _act  
File Role Description
  Accessible without login Plain text file download.php Aux. Auxiliary script

  Files folder image Files  /  pri  /  sys  /  _lib  
File Role Description
  Plain text file Base.php Class Class source
  Plain text file Common.php Class Class source
  Plain text file Database.php Class Class source
  Plain text file IData.php Class Class source
  Plain text file Mypdo.php Class Class source
  Plain text file Texts.php Class Class source

  Files folder image Files  /  pri  /  sys  /  _tpl  
File Role Description
  Accessible without login Plain text file exit.phtml Data Auxiliary data
  Accessible without login Plain text file exits.phtml Data Auxiliary data

  Files folder image Files  /  pub  
File Role Description
Files folder imagecss (2 files)
Files folder imagejs (2 files)
Files folder imagepic (1 file)

  Files folder image Files  /  pub  /  css  
File Role Description
  Accessible without login Plain text file base.css Data Auxiliary data
  Accessible without login Plain text file msie.css Data Auxiliary data

  Files folder image Files  /  pub  /  js  
File Role Description
  Accessible without login Plain text file base.js Data Auxiliary data
  Accessible without login Plain text file common.js Data Auxiliary data

  Files folder image Files  /  pub  /  pic  
File Role Description
  Accessible without login Image file favicon.ico Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:242
This week:0
All time:8,004
This week:83Up