|
|
|
|
|
|
AddValue |
AddValue (
string |
$field |
string |
$value |
boolean |
$sqlFunction = false |
) |
Arguments:
Name |
Description |
$field |
The name of the field in the table where you want to add some value to |
$value |
The value you would like to add |
$sqlFunction |
Should the value being interpretaded as a SQL function (Like for example NOW() in MySQL)? |
Description:
With this funciton you can add a value to the form results (like a hidden field, only without one).
This is very handy is you want to add some data into the database with not have to be shown in the form (like the date of insert).
You can also overwrite a value of a existing field!
Example
<?php
// include the class
include("FH3/class.FormHandler.php");
// create new formhandler object
$form = new FormHandler();
// passfield
$form -> passField("Password", "password", FH_STRING);
// get the value of the field
$value = $form->value("password");
// save the password MD5 encrypted
// so OVERWRITE the current value!!
$form->addValue(
"password",
"MD5('". mysql_escape_string( $value ) ."')",
true # the value should be interpretated as a SQL statement
);
// submitbutton
$form -> submitButton("Save");
// set the onCorrect function
$form -> onCorrect("doRun");
// flush
$form -> flush();
// commit after form function
function doRun($data)
{
echo "MD5 encrypted password: ".$data['password'];
}
?>
|
Latest change: 05 March 10 / 08:52
Comments
|
|
|
|