НА лендосе есть форма
<form action="handler.php" method="POST" class="send_to_crm">
<input type="text" name="name" placeholder="Ваше Имя" required>
<input type="email" name="email" placeholder="Ваша e-mail" required>
<input type="tel" name="phone" placeholder="Ваше номер телефона" id="phone" required>
<input type="submit" value="Отправить">
</form>
файл amoform.php
<?php
# Create a link for request
$link='https://forms.amocrm.ru/queue/add';
$fields=array(
'fields[name_1]'=> urlencode($_POST['name']),
'fields[164585_1][330119]'=> urlencode($_POST['email']),
'fields[164583_1][330107]'=> urlencode($_POST['phone']),
'fields[217871_2]'=> urlencode($_POST['utm_medium']),
'fields[217869_2]'=> urlencode($_POST['utm_source']),
'fields[217873_2]'=> urlencode($_POST['utm_campaign']),
'fields[217875_2]'=> urlencode($_POST['utm_term']),
'fields[217877_2]'=> urlencode($_POST['overseer']),
'form_id'=> 354166,
'hash' => 'f1d4eb67587a61f75d4ee5b30b245b4a'
);
//url-ify the data for the POST
$fields_string = '';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$curl = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($curl,CURLOPT_URL, $link);
curl_setopt($curl,CURLOPT_POST, count($fields));
curl_setopt($curl,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$out = curl_exec($curl);
//close connection
curl_close($curl);
//var_dump($out);
?>
файл handler.php
<?php
$root=__DIR__.DIRECTORY_SEPARATOR;
require $root.'amoform.php';
header("Location: АДРЕС_САЙТА/thank-you.htm");
exit();
?>
Вместо переадресации на страницу благодарности выводит такую ошибку:
{"error_code":400,"msg":"invalid_data"}
Warning: Cannot modify header information - headers already sent by (output started at /АДРЕС_САЙТА/amoform.php:33) in / /АДРЕС_САЙТА/handler.php on line 5