Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Database Functions  /  dbConnect

dbConnect
dbConnect (
string $host = null,
string $username = "",
string $password = "" 
)

Arguments:

Name Description
$host The host where the database is located. This could also be the server name for some types of databases. When no host is given, the host saved with the var FH_DEFAULT_DB_HOST from the configuration file is used.
$username The username which should be used loggin in into the database.
$password The password which should be used loggin in into the database.

Description:

Create a new connection to the database after setting the database data with the function dbInfo().

Note: You can only use these functions if you make use of the dbFormHandler class! So, include class.dbFormHandler.php and create a new FormHandler object with the constructor dbFormHandler().

Note: If you want to use an already opened connection, please use setConnectionResource().

Example

<?php 

// include the class 
include('FH3/class.dbFormHandler.php'); 

// create new formhandler object 
$form =& new dbFormHandler(); 

// Set the database info and connect! (Create a new connection)
$form->dbInfo"myDB""myTable" ); 
$form->dbConnect"localhost""username""password" ); 

// some fields + button 
$form->textField("Name""name"FH_STRING2050); 
$form->textField("Age""age"FH_INTEGER33); 
$form->selectField("Gender""gender", array('M''F'), nullfalse); 

$form->submitButton("Save"); 

// data handling 
// MAKE SURE YOU USE ONSAVED! 
$form->onSaved("doRun"); 


// display the page 
$form->flush(); 

// the data handler 
function doRun$id$data 

    echo 
    
"Hello "$data['name'] ."\n"
    
"Your data is saved!\n"

?>

See also: dbFormHandler  |  dbInfo  |  SetConnectionResource

Latest change: 27 June 08 / 09:27

Comments

powered by PHP-GLOBE   © 2004 - 2024 FormHandler. All rights reserved.   -   Open source license