I'm using Contact Form 7 for Wordpress and I send data to a CRM with :
JS file
- map form data with
var data_one = event.detail.inputs[0].value;
var data_two = event.detail.inputs[1].value;
- and send data with Ajax
jQuery.ajax({
method: "POST",
url: post_url,
data: {
name: data_one,
email: data_two
},
cache: false
}).done(function( html ) {
- PHP file
$data = array(
'User' => 'AdmWbs',
'Password' => '**********',
'name' => $_POST['name'],
'email' => $_POST['email']
);
# Create a connection
$url = 'http://...'; //url or webservice
$ch = curl_init($url);
# Form data string
$postString = http_build_query($data, '', '&');
# Setting our options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
# Get the response
$response = curl_exec($ch);
//if there is an error send email to sys admin and do a redirect to home
if (strpos($response, 'abortProcessing') !== false) {
sendMail("2",$response,$_POST['idprovenienza'],$_POST['email'],$_POST['indirizzoip']);
header("Location: https://www.test.com/");
die();
}
curl_close($ch);
problem is the, randomly, if an user send a form we find 1, 2, ... 10 same lead on CRM
How I can block to send only 1 time per form send?
Thanks
Send one 1 data per sending form