FormBoss 2 Documentation
Top Link
Sortable Page Simple SQL

In Brief: Send the result of this form to the FormBoss Internal Result Browser.

Dependencies: A valid SQL results table.

Hints & Tricks: Use this module to send the results of a form submission to the internal FormBoss SQL Result Browser. All fields and data are handled automatically--this is the most simple of form delivery methods.

Options/Properties

Basic Attributes

Design Notes
These are notes you can input that help you and other production staff understand your confirmation elements logic and purpose. This text is never used in the live form in any way, it is only for internal development.

Data Source

DB Connector File
If you input an absolute path into this box, FormBoss will use that file for all database connection information for this query. This means you can 'secure' your forms by making sure access to important database information is limited to only those with access to this file.

It is important to note that if you leave this field blank FormBoss will by default include the /app/movefiles/congif.php file in your job folder and use the contents of that file for Database connectivity. This means in most cases the simple solution is to not provide a value for this field and let FormBoss perform the 'default' action.

To create your own Db Connector File, simply copy the contents of your existing config.php file from your /app/movefiles/ directory and paste it into a new file.

You will then need to change the values of these fields to match the values of the datasource you wish to use:

$db_type = 'mysql';
$db_host = 'localhost';
$mysql_socket = '';
$mysql_port = '';
$db_user = 'formboss';
$db_pass = 'test';

$db_catalog = 'formboss';

Now in the DB Connector File field place the path to the file you just created relative to your forms final destination. For example, by default all FormBoss output is placed in:

formboss/output/forms/

Which means if I placed my DB Connector file in:

formboss/output/forms/config.php

My DB Connector File would have:

../config.php

as this file would indeed be one directory up from my form, which if was called external_db, would be located at:

formboss/output/forms/external_db

Now when we run the form FormBoss will not use the config.php file located in the job folder (indeed, one will not even be created unless I have a File Upload module in my form that doesn't also have a DB Connector File specified), which means in principal, any users with access to the FormBoss job folder will never see any database login info, and so long as they did not have access to the folder with the External DB Connector File, not see any DB information period.

Confirmation/Query Condition

Confirmation Condition PHP Code
This field allows you to specify a condition which must be met for the confirmation field to be processed.

The logic takes the form of:

Variable 1 | Condition | Variable 2

For example, let's assume we have a radio item in our form with the Name/Value of opt_1. The radio item has two possible vales, 'Yes' and 'No'. If the value of opt_1 is 'Yes' we want to send an email, if no, we do not.

We would write the Confirmation Condition PHP Code as such:

#{opt_1} == 'Yes'

In other words, we use the token for our field variable like we would in other property boxes, that is, a pound sign (#) followed by the Name/Value of the field in braces. Recall that at run time this token evaluates to the value set by our forms users, which in this case will be the value of the radio button with the Name/Value of opt_1.

We then set the comparison, in this case out comparison is equal too, denoted with the double == sign. Finally, because we know our radio item is a string value that can be 'Yes' or 'No', we wrap the value we want to check for in single tick marks.

On the raw code side, FormBoss wraps the token call in an isset() block, which is further wrapped in the proper PHP if() syntax:

if(isset($_SESSION['qs']["{$_SESSION['entry_key']}"]['opt_1']) && $_SESSION['qs']["{$_SESSION['entry_key']}"]['opt_1'] == 'Yes') { // condition code start

When run, if the users set value for the radio box was 'Yes', we would process this confirmation element.

Using Array Based Form Elements (Checkboxes)
PHP Treats checkbox items a little differently than other elements. The good news is the only element that needs this special attention is a checkbox field. The difference then, is that in order to use checkbox items we need to place an index indicator just after the field Name/Value token.

For example, lets say we have a checkbox field that had the Name/Value: email_condition and has two elements: Recipient A and Recipient A

To process this field in our condition statement we need to append the proper index of the field used for checking the condition using PHP array index format. It may sound confusing, but it's quite simple when you see it:

#{email_condition[0]} == 'Recipient A'

In short, the non-array way would be to simply use:

#{email_condition} == 'Recipient A'

But because we need to check an array index (again, because PHP treats checkbox items as arrays), we simply add the [0] part before the closing brace (}).

How do we know which array index to use (the number part)? In our example the checkbox field has two values; array indexs start with 0, so the first field, Recipient A, is [0], where Recipient B would be [1].

This numbering simply climbs up by 1 for every checkbox item you add.

top