Aug 5th, 2013, 10:13 AM
(This post was last modified: Aug 5th, 2013, 10:20 AM by webfoundry.)
Hi all,
I'm new in this forum, and a new happy user of Form Tools.
I read a lot of the tutorials, but one thing is not clear to me :
I use validation (see code), but I get a lot of nulled out submissions in my database.
Is there something wrong so submissions aren't validated properly, or is the submission not passed to the database in a proper way ?
Some of the submissions are filled in, so not all of them are nulled.
Some examples for the few hundred submissions wich seems nulled out :
submission_id naam mail submission_date last_modified_date ip_address is_finalized confirmed
26 NULL NULL 2013-07-21 22:17:34 2013-07-21 22:17:34 xx.xxx.76.180 no NULL
27 NULL NULL 2013-07-22 00:55:38 2013-07-22 00:55:38 xxx.xxx.55.104 no NULL
28 NULL NULL 2013-07-22 02:26:08 2013-07-22 02:26:08 xxx.xxx.185.154 no NULL
29 NULL NULL 2013-07-22 04:08:41 2013-07-22 04:08:41 xxx.xx.32.133 no NULL
30 NULL NULL 2013-07-22 04:18:02 2013-07-22 04:18:02 xx.xxx.174.129 no NULL
31 NULL NULL 2013-07-22 04:53:32 2013-07-22 04:53:32 xxx.xx.102.159 no NULL
32 NULL NULL 2013-07-22 06:01:14 2013-07-22 06:01:14 xx.xxx.73.131 no NULL
33 NULL NULL 2013-07-22 08:51:26 2013-07-22 08:51:26 xx.xx.9.151 no NULL
This is my php header:
<?php
require_once("../wedstrijdformulier/global/api/api.php");
$fields = ft_api_init_form_page(4);
$errors = array();
if (isset($_POST["submit_button"]))
{
$rules = array();
$rules[] = "required,naam,don't forget to fill in your name.";
$rules[] = "required,mail,don't forget to fill in your email.";
$rules[] = "valid_email,mail,use a valid emailaddress.";
$rules[] = "required,akkoord,you need to accept the conditions.";
$errors = validate_fields($_POST, $rules);
$criteria = array("mail" => $_POST["mail"]);
if (!ft_api_check_submission_is_unique(4, $criteria, $fields["form_tools_submission_id"]))
{
$errors[] = "Sorry, this email already participated.";
}
// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
if (empty($errors))
{
$params = array(
"submit_button" => "submit_button",
"next_page" => "thankyou.php",
"form_data" => $_POST,
"finalize" => true
);
ft_api_process_form($params);
}
// it failed validation. Update $fields with the latest contents of the form data
else
{
$fields = array_merge($_SESSION["form_tools_form"], $_POST);
}
}
?>
P.S. :
If I understand from http://forums.formtools.org/showthread.p...=finalized it is normal to have a lot of unfinalized submissions in your database, so I guess I shouldn't worry.
I just wanted to be sure as of 150 submissions in the form, only 7 of them are finalized, wich seems extremely low, wich makes me a little panicky.
I'm new in this forum, and a new happy user of Form Tools.
I read a lot of the tutorials, but one thing is not clear to me :
I use validation (see code), but I get a lot of nulled out submissions in my database.
Is there something wrong so submissions aren't validated properly, or is the submission not passed to the database in a proper way ?
Some of the submissions are filled in, so not all of them are nulled.
Some examples for the few hundred submissions wich seems nulled out :
submission_id naam mail submission_date last_modified_date ip_address is_finalized confirmed
26 NULL NULL 2013-07-21 22:17:34 2013-07-21 22:17:34 xx.xxx.76.180 no NULL
27 NULL NULL 2013-07-22 00:55:38 2013-07-22 00:55:38 xxx.xxx.55.104 no NULL
28 NULL NULL 2013-07-22 02:26:08 2013-07-22 02:26:08 xxx.xxx.185.154 no NULL
29 NULL NULL 2013-07-22 04:08:41 2013-07-22 04:08:41 xxx.xx.32.133 no NULL
30 NULL NULL 2013-07-22 04:18:02 2013-07-22 04:18:02 xx.xxx.174.129 no NULL
31 NULL NULL 2013-07-22 04:53:32 2013-07-22 04:53:32 xxx.xx.102.159 no NULL
32 NULL NULL 2013-07-22 06:01:14 2013-07-22 06:01:14 xx.xxx.73.131 no NULL
33 NULL NULL 2013-07-22 08:51:26 2013-07-22 08:51:26 xx.xx.9.151 no NULL
This is my php header:
<?php
require_once("../wedstrijdformulier/global/api/api.php");
$fields = ft_api_init_form_page(4);
$errors = array();
if (isset($_POST["submit_button"]))
{
$rules = array();
$rules[] = "required,naam,don't forget to fill in your name.";
$rules[] = "required,mail,don't forget to fill in your email.";
$rules[] = "valid_email,mail,use a valid emailaddress.";
$rules[] = "required,akkoord,you need to accept the conditions.";
$errors = validate_fields($_POST, $rules);
$criteria = array("mail" => $_POST["mail"]);
if (!ft_api_check_submission_is_unique(4, $criteria, $fields["form_tools_submission_id"]))
{
$errors[] = "Sorry, this email already participated.";
}
// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
if (empty($errors))
{
$params = array(
"submit_button" => "submit_button",
"next_page" => "thankyou.php",
"form_data" => $_POST,
"finalize" => true
);
ft_api_process_form($params);
}
// it failed validation. Update $fields with the latest contents of the form data
else
{
$fields = array_merge($_SESSION["form_tools_form"], $_POST);
}
}
?>
P.S. :
If I understand from http://forums.formtools.org/showthread.p...=finalized it is normal to have a lot of unfinalized submissions in your database, so I guess I shouldn't worry.
I just wanted to be sure as of 150 submissions in the form, only 7 of them are finalized, wich seems extremely low, wich makes me a little panicky.