Examples – PHP Database Form https://phpdatabaseform.com Generate web form from database. Simple. Sat, 27 Dec 2014 01:32:07 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.4 Introduction https://phpdatabaseform.com/examples/introduction-2/ Thu, 03 Jul 2014 18:50:47 +0000 http://phpdatabaseform.com/?p=286 PHP Database Form builds amazing online forms with ease. It is designed for web developers, freelancers, IT consultants who wish to create professional online form quickly with minimum programming.

A basic web form requires only two lines of PHP code.

]]>
Quick Setup https://phpdatabaseform.com/examples/quick-setup/ Thu, 03 Jul 2014 18:55:14 +0000 http://phpdatabaseform.com/?p=290 Setup PHP Database Form is easy and very similar to setting up phpgrid by updating a few values in conf.php file.

Make sure to use the correct PDBF_PATH value. It represents the absolute URL to the phpDatabaseForm library folder on the web server. This value tells your script where to find phpDatabaseForm library on the web server.

For instance, if the URL to get to the PHP Database Form is http://www.yoursite.com/phpDatabaseForm, or http://localhost/phpDatabaseForm, the PDBF_PATH should be “/phpDatabaseForm”.

if the URL to phpDatabaseForm is http://www.yoursite.com/admin/phpDatabaseForm, or http://localhost/admin/phpDatabaseForm, the PDBF_PATH should be “/admin/phpDatabaseForm”,

and so forth.

The sample MySQL database “northwind” can be found inside examples/SampleDB folder.

// mysql example
define('PDBF_DB_HOSTNAME', 'localhost:3306'); // database host name
define('PDBF_DB_USERNAME', 'root'); // database user name
define('PDBF_DB_PASSWORD', ''); // database password
define('PDBF_DB_NAME', 'northwind'); // database name
define('PDBF_DB_TYPE', 'mysql'); // database type
define('PDBF_DB_CHARSET','utf8'); // ex: utf8(for mysql),AL32UTF8 (for oracle), leave blank to use the default charset

define('PDBF_PATH', '/phpDatabaseForm');

/******** DO NOT MODIFY ***********/
require_once('pdbf.php');
/**********************************/
]]>
Database Type https://phpdatabaseform.com/examples/database-type/ Thu, 03 Jul 2014 18:56:21 +0000 http://phpdatabaseform.com/?p=334

databases_supported

PHP Database Form supports wide range of database types. Simply define PDBF_DB_TYPE parameter value to your own database type. It can be one of the following strings. The default database type for is “mysql”.

PDBF_DB_TYPE string is case sensitive.

PDBF_DB_TYPE Description
mysql MySQL (default)
odbc_mssql SQL Server (Unix/Linux)
odbc_mssql_native SQL Server Windows native (Download PHP SQL Server Driver)
oci805 Oracle
postgres PostGreSql
access Microsoft Access
db2 DB2
db2-dsnless DB2 DSN-less connection
informix Informix
informix72 Alternative Informix Driver
odbc Generic ODBC

]]> Build Your First Online Form https://phpdatabaseform.com/examples/build-first-online-form/ Thu, 03 Jul 2014 18:58:45 +0000 http://phpdatabaseform.com/?p=287 Build your first web form in two lines of PHP code. Below example generates the form from a database table named “employees”. When using star, it generates a web form with each form element ordered by database table column from the left most column to right most.

e.g.

SELECT * FROM...

or you can specify column names that only will be used. In this case, phpDatabaseForm generates form element only by the order column names specified.

SELECT col1, col2, col3... FROM...

At minimum, it requires only TWO lines of code.

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> display();

Live demo

]]>
Change Form Element Label https://phpdatabaseform.com/examples/change-label/ Sun, 06 Jul 2014 00:39:35 +0000 http://phpdatabaseform.com/?p=295 By default form displays database column name as input element label. You can change it with method set_label().

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> set_label("EmployeeID", "Employee ID");
$dbForm -> set_label("LastName", "Last Name");
$dbForm -> set_label("FirstName", "First Name");
$dbForm -> set_label("BirthDay", "DOB");
$dbForm -> display();

Live demo

]]>
Hide A Form Element https://phpdatabaseform.com/examples/hide-a-form-element/ Sun, 06 Jul 2014 00:47:44 +0000 http://phpdatabaseform.com/?p=296 You can choose to hide certain fields from displayed on the form with set_hide() method.

Note set_hide() method hides the form elements using display:none in CSS. You should not use it to hide sensitive information such as password.

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> set_label("EmployeeID", "Employee ID");
$dbForm -> set_label("LastName", "Last Name");
$dbForm -> set_label("FirstName", "First Name");
$dbForm -> set_label("BirthDay", "DOB");
$dbForm -> set_hide("Extension");
$dbForm -> set_hide("hireDate");
$dbForm -> display();

Live demo

]]>
Set Placeholder https://phpdatabaseform.com/examples/set-placeholder/ Sun, 06 Jul 2014 00:50:04 +0000 http://phpdatabaseform.com/?p=298 Use set_placeholder to set placeholder text for an input element.

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> set_label("EmployeeID", "Employee ID");
$dbForm -> set_label("LastName", "Last Name");
$dbForm -> set_label("FirstName", "First Name");
$dbForm -> set_label("BirthDay", "DOB");
$dbForm -> set_hide("Extension");
$dbForm -> set_hide("hireDate");
$dbForm -> set_placeholder('Title', 'official job title');
$dbForm -> display();

Live demo

]]>
Required Fields https://phpdatabaseform.com/examples/required-fields/ Sun, 06 Jul 2014 00:56:35 +0000 http://phpdatabaseform.com/?p=299 To set field as required, use set_required() method. If required fields are left blank, an “* required” message will be displayed. One more more fields can be specified as required fields in this method.

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> set_label("EmployeeID", "Employee ID");
$dbForm -> set_label("LastName", "Last Name");
$dbForm -> set_label("FirstName", "First Name");
$dbForm -> set_label("BirthDay", "DOB");
$dbForm -> set_hide("Extension");
$dbForm -> set_hide("hireDate");
$dbForm -> set_placeholder('Title', 'official job title');
$dbForm -> set_required(array("LastName"));
$dbForm -> display();

Sample output:

require_field_error

Live demo

]]>
Add A Section Header https://phpdatabaseform.com/examples/add-section-header/ Mon, 07 Jul 2014 19:30:55 +0000 http://phpdatabaseform.com/?p=300 You can divid a form into multiple subsections each with different header text. Use add_group_header() for this purpose.

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> set_label("EmployeeID", "Employee ID");
$dbForm -> set_label("LastName", "Last Name");
$dbForm -> set_label("FirstName", "First Name");
$dbForm -> set_label("BirthDay", "DOB");
$dbForm -> set_hide("Extension");
$dbForm -> set_hide("hireDate");
$dbForm -> set_placeholder('Title', 'official job title');
$dbForm -> add_group_header("EmployeeID", "Basic Info");
$dbForm -> add_group_header("Email", "Contact Info");
$dbForm -> display();

Sample Output:

section_header

Live demo

]]>
Tooltip https://phpdatabaseform.com/examples/tooltip/ Mon, 07 Jul 2014 20:14:19 +0000 http://phpdatabaseform.com/?p=301 The tooltip is a hint that displays information about an item being hovers over by mouse pointer. Tooltips do not appear on mobile operating systems, because there is no cursor. Use add_tooltip() to add tooltip to any form element by name. The default tooltip symbol is a question mark (?).

tooltip

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> set_label("EmployeeID", "Employee ID");
$dbForm -> set_label("LastName", "Last Name");
$dbForm -> set_label("FirstName", "First Name");
$dbForm -> set_label("BirthDay", "DOB");
$dbForm -> set_hide("Extension");
$dbForm -> set_hide("hireDate");
$dbForm -> set_placeholder('Title', 'official job title');
$dbForm -> add_group_header("EmployeeID", "Basic Info");
$dbForm -> add_group_header("Email", "Contact Info");
$dbForm -> add_tooltip("BirthDate", "Enter employee birth date"); // tooltip supports HTML as well
$dbForm -> display();

Live demo

]]>