Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Database Functions  /  dbFormHandler

(Since version FH3-v1.2)

dbFormHandler
dbFormHandler (
string $name = null,
string $action = null,
mixed $extra = null 
)

Arguments:

Name Description
$name The name of the form. When none is given, a unique name will be generated.
$action The action of the form. By default this is the same URL as the one which was called to display the form. When you set this to another URL formhandler cannot check the form! Make sure it's pointing to itsself!
$extra This can be extra information which will be included in the form's html tag. You can add for example some CSS or javascript.

Description:

With this function you can create a new FormHandler object with database supporting enabled. For performance reasons it is recommended to use FormHandler() if you dont use one of the database functions!!

Example

<?php 
/** 
* Your Database Connection (In This Example MySQL) 
*/ 
$connection mysql_connect"localhost""username""password" ); 

// connection made ? 
if( $connection 

    
// select the database 
    
if( !mysql_select_db"database"$connection ) ) 
    { 
        
// could not select database! 
        
die('Could not select the database! Error: ' mysql_error() ); 
    } 

// could not connect to the database 
else 

    die(
'Could not make a connection to the database! Error: ' mysql_error() ); 


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

// create a new form 
$form = new dbFormHandler(); 

// set the database info 
$form -> setConnectionResource$connection"myTable""mysql" ); 

// fields..
$form -> textField('Test''myField'FH_STRING );

// here comes the rest of the form 
// ............ 

// set the data handler 
// (NOTE the onSaved, this is different then onCorrect!) 
$form -> onSaved("doSomething"); 

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

// the data handler... 
// NOTE the two arguments!!!! 
function doSomething$id$data 

    
// do something here... 


?>

Latest change: 05 March 10 / 08:54

Comments

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