mail.php 1.15 KB
<?php
	require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
	CModule::IncludeModule("iblock");
	header('Content-type: application/json');

	if($_REQUEST['send_form'] == 'Y') {

		$el = new CIBlockElement;
		$PROP = [];
		$PROP[16] = strip_tags($_REQUEST['phone']);
		$PROP[17] = strip_tags($_REQUEST['email']);
		$PROP[18] = strip_tags($_REQUEST['company']);

		$name = 'Сообщение от ' . strip_tags($_REQUEST['first_name']) . ' за ' . date('d.m.Y H:i:s');

		$arLoadProductArray = [
			'IBLOCK_ID' => IBID_FEEDBACK,
			'PROPERTY_VALUES' => $PROP,
			'NAME' => $name,
			'PREVIEW_TEXT' => strip_tags($_REQUEST['comment']),
			'ACTIVE' => 'Y',
		];

		if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
			$to_send = [];
			$to_send['AUTHOR_EMAIL'] = strip_tags($_REQUEST['email']);
			$to_send['AUTHOR'] = strip_tags($_REQUEST['first_name']);
			$to_send['PHONE'] = strip_tags($_REQUEST['phone']);
			$to_send['COMPANY'] = strip_tags($_REQUEST['company']);
			$to_send['TEXT'] = strip_tags($_REQUEST['comment']);

			CEvent::SendImmediate ('FEEDBACK_FORM', SITE_ID, $to_send);
		} else {
			echo 'Error: ' . $el->LAST_ERROR;
		}
	}