Oct 28th, 2013, 9:58 AM
(This post was last modified: Oct 28th, 2013, 10:08 AM by webfoundry.)
I thought this module would solve it, but it looks like it only handles "users", and not form-submitters.
We don't have a problem with unauthorized users, but someone who is filling in front-end forms, always with different e-mailadresses so he bypasses the unique email-checker, so the submission-list is getting filled with non-existing e-mailadresses, all coming from the same IP-address.
my code :
We don't have a problem with unauthorized users, but someone who is filling in front-end forms, always with different e-mailadresses so he bypasses the unique email-checker, so the submission-list is getting filled with non-existing e-mailadresses, all coming from the same IP-address.
my code :
PHP Code:
<?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,Vergeet je naam niet in te vullen.";
$rules[] = "required,mail,Vergeet je e-mailadres niet in te vullen.";
$rules[] = "valid_email,mail,Voer een geldig e-mailadres in.";
$rules[] = "required,akkoord,Je moet akkoord gaan met de actievoorwaarden.";
$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, dit e-mailadres heeft reeds deelgenomen aan onze wedstrijd.";
}
// 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);
}
}
?>