I have a form that collects names, emails, and positions. While my PHP code successfully sends the names and emails to Bitrix as new leads, the position data is not being transmitted.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
$position = filter_input(INPUT_POST, 'position', FILTER_SANITIZE_STRING);
$webhookUrl = 'https://b24-zXXXXXXXXXXXXXXXXXXXXXX/crm.lead.add.json';
$postData = http_build_query([
'fields' => [
'TITLE' => $name,
'EMAIL' => [['VALUE' => $email, 'VALUE_TYPE' => 'WORK']],
'POSITION' => [['VALUE' => $position, 'VALUE_TYPE' => 'WORK']],
],
'params' => ["REGISTER_SONET_EVENT" => "Y"]
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $webhookUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo $response;
header("Location: " . $_SERVER['PHP_SELF']);
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>FORM</title>
</head>
<body>
<form action="" method="post">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br><br>
<label for="email">E-mail:</label><br>
<input type="email" id="email" name="email"><br><br>
<label for="position">Position:</label><br>
<input type="text" id="position" name="position"><br><br>
<input type="submit" value="SUBMIT">
</form>
</body>
</html>
I wonder how should it sends position value to Bitrix24.