Created
August 25, 2021 19:14
-
-
Save if0rest/c10cdfe4266521d9d9466d628b83758c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");?> | |
<? | |
define("NO_KEEP_STATISTIC", true); | |
define("NOT_CHECK_PERMISSIONS", true); | |
use Bitrix\Main\Application; | |
use Bitrix\Main\Loader; | |
$request = Application::getInstance()->getContext()->getRequest(); | |
// Get $_POST data via D7 | |
$postValues = $request->getPostList()->toArray(); | |
if (!empty($postValues['name']) && !empty($postValues['surname']) | |
&& !empty($postValues['patronymic']) && !empty($postValues['age'])) | |
{ | |
if (!Loader::includeModule('iblock')) | |
die('Не удалось подключить модуль "Инфоблоки"'); | |
//Погнали | |
$el = new CIBlockElement; | |
$IBLOCK_ID = 6; | |
$PROPS = array(); | |
$PROPS['NAME'] = $postValues['name']; | |
$PROPS['SURNAME'] = $postValues['surname']; | |
$PROPS['PATRONYMIC'] = $postValues['patronymic']; | |
$PROPS['AGE'] = $postValues['age']; | |
$PROPS['EMAIL'] = $postValues['email']; | |
//Основные поля элемента | |
$fields = array( | |
"IBLOCK_ID" => $IBLOCK_ID, | |
"NAME" => strip_tags($postValues['name']), | |
"ACTIVE" => "Y", | |
"DATE_CREATE" => date("d.m.Y H:i:s"), | |
"CREATED_BY" => $GLOBALS['USER']->GetID(), | |
"PROPERTY_VALUES" => $PROPS, | |
); | |
//Результат в конце отработки | |
if ($ID = $el->Add($fields)) { | |
echo "Сохранено. ID элемента {$ID}"; | |
} else { | |
echo 'Произошел какой-то косяк Попробуйте еще разок'; | |
} | |
} else { | |
echo 'Незаполнены поля.'; | |
} | |
?> | |
<?require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment