-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.php
52 lines (41 loc) · 1.57 KB
/
process.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* File: process.php
*
* This file processes any form submissions for forms already added and configured within Form Tools. To
* use it, just point your form to this file, like so:
*
* <form method="post" action="/path/to/process.php">
*
* Once the form has been added through the Form Tools UI, this script parses the form contents
* and adds it to the database then redirects the user to whatever page is required. In addition,
* this script is used to initially set up the form within the database, to map input fields to
* database columns and types.
*/
use FormTools\Core;
use FormTools\Forms;
use FormTools\Submissions;
use FormTools\Themes;
// always include the core library functions
require_once(__DIR__ . "/global/library.php");
// if the API is supplied, include it as well
@include_once(__DIR__ . "/global/api/api.php");
Core::init();
$LANG = Core::$L;
// check we're receiving something
if (empty($_POST)) {
$page_vars = array("message_type" => "error", "message" => $LANG["processing_no_post_vars"]);
Themes::displayPage("error.tpl", $page_vars);
exit;
// check there's a form ID included
} else if (empty($_POST["form_tools_form_id"])) {
$page_vars = array("message_type" => "error", "message" => $LANG["processing_no_form_id"]);
Themes::displayPage("error.tpl", $page_vars);
exit;
// is this an initialization submission?
} else if (isset($_POST["form_tools_initialize_form"])) {
Forms::initializeForm($_POST);
// otherwise, it's a regular form submission. Process it!
} else {
Submissions::processFormSubmission($_POST);
}