Hello all. I've got some validation on my form and it works beautifully. Problem is that every time there's an error, the data is not retained in the form, causing the users to have to re-enter it every time.
Here's my pertinent code:
<?php
require_once("/wamp/www/ah/global/api/api.php");
$fields = ft_api_init_form_page(5, "live", "form5");
$errors = array();
if (isset($_POST["submit"]))
{
$rules = array();
$rules[] = "if:element_27!=,required,element_57,Please enter misc details.";
$errors = validate_fields($_POST, $rules);
$criteria = array(
"col_2" => $_POST["element_1"],
"col_1" => $_POST["element_22"]
);
if (!ft_api_check_submission_is_unique(5, $criteria, $fields["form_tools_submission_id"]))
{
$errors[] = "Sorry, you have already placed a submission for this date range. Please contact the appropriate staff to modify your previous entry.";
}
if (empty($errors))
{
$params = array(
"namespace" => "form5",
"submit_button" => "submit",
"next_page" => "thankyouhims.php",
"form_data" => $_POST,
"finalize" => true
);
ft_api_process_form($params);
}
else
{
$fields = array_merge($_SESSION["form_tools_form"], $_POST);
}
}
?>
Help!
Here's my pertinent code:
<?php
require_once("/wamp/www/ah/global/api/api.php");
$fields = ft_api_init_form_page(5, "live", "form5");
$errors = array();
if (isset($_POST["submit"]))
{
$rules = array();
$rules[] = "if:element_27!=,required,element_57,Please enter misc details.";
$errors = validate_fields($_POST, $rules);
$criteria = array(
"col_2" => $_POST["element_1"],
"col_1" => $_POST["element_22"]
);
if (!ft_api_check_submission_is_unique(5, $criteria, $fields["form_tools_submission_id"]))
{
$errors[] = "Sorry, you have already placed a submission for this date range. Please contact the appropriate staff to modify your previous entry.";
}
if (empty($errors))
{
$params = array(
"namespace" => "form5",
"submit_button" => "submit",
"next_page" => "thankyouhims.php",
"form_data" => $_POST,
"finalize" => true
);
ft_api_process_form($params);
}
else
{
$fields = array_merge($_SESSION["form_tools_form"], $_POST);
}
}
?>
Help!