довольно плохо знаком с drupal, и я столкнулся с проблемой при попытке вставить данные в мою базу данных из формы.
Сама форма создается из js в папке моей темы,
$('.register')
.find('.title_block')
.addClass('reg-details')
.append('<div id="emailRegister" class="modal"><div class="modal-content">
<span class="close">×</span><br><br><p>We have detected that you
are on a mobile device. It can
take up to 2 minutes to fill out the required profile.</p><p>If you
would like to finish this
profile at a later time, we can email it to you.</p><p>Otherwise,
select Close to proceed!</p>
<form method="post" action="/register.php" enctype="multipart/form-
data">First name:<br><input
type="text" class="emailFields" name="firstname" value=""><br>Last
name:<br><input type="text"
class="emailFields" name="lastname" value=""><br>Email:<br><input
type="email"
class="emailFields" id="regEmail" name="email"><br><input type="submit"
value="Submit"><br>
</form><button type="submit" id="closeModal"
style="background:grey">Close</button>')
.insertBefore('.lms-main-container');
Страница действий находится в корне моей папки
<?php
require 'vendor/autoload.php';
use Drupal\docebo_login\FormaNotification;
$email = $fname = $lname = "";
$email = $_POST["email"];
$fname = $_POST["firstname"];
$lname = $_POST["lastname"];
if ($email == "" || $fname == "" || $lname == "") {
header("Location: http://example.com");
exit();
}
$noti = new FormaNotification();
$result = $noti->getRegister($fname, $lname, $email);
$auth = array('api_key' => 'some=key=here');
# The unique identifier for this smart email
$smart_email_id = 'email-id';
# Create a new mailer and define your message
$wrap = new CS_REST_Transactional_SmartEmail($smart_email_id, $auth);
$message = array(
"To" => $email,
"Data" => array(
'variableName' => 'variableNameTestValue',
'x-apple-data-detectors' => 'x-apple-data-detectorsTestValue',
'href^="tel"' => 'href^="tel"TestValue',
'href^="sms"' => 'href^="sms"TestValue',
'owa' => 'owaTestValue',
'role=section' => 'role=sectionTestValue',
'style*="font-size:1px"' => 'style*="font-size:1px"TestValue',
),
);
# Add consent to track value
$consent_to_track = 'no'; # Valid: 'yes', 'no', 'unchanged'
# Send the message and save the response
$result = $wrap->send($message, $consent_to_track);
if ($result) {
header("Location: /");
exit();
}
Как видите, я вызываю функцию из модулей моей темы, вот функция
public function getRegister($fname, $lname, $email) {
return parent::insertRegister($fname, $lname, $email);
}
Который затем передает переменные этой функции в ее родительском
public function insertRegister($fname, $lname, $email) {
db_set_active('docebo');
$this->setConnection('dev-db');
$result = $this->getConnection()->insert('register')
->fields([
'fistName' => $fname,
'lastName' => $lname,
'email' => $email,
'dateAdded' => REQUEST_TIME,
])
->execute();
db_set_active();
}
Теперь я могу быть наивным, но я подумала, что так оно и будет. Но когда я отправляю форму, я получаю уведомление об ошибке 500. Когда я удаляю вставку из действия формы, форма работает как ожидалось.
Я попытался получить лучшее сообщение об ошибке, чтобы помочь мне, т.е. проверил мой файл settings.php, чтобы убедиться, что отчеты об ошибках были подробными, даже пытаясь установить его в моем ini.php или поместив
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
на самой странице действия формы и все равно ничего не получите. Похоже, в моих журналах тоже ничего нет. Так что я довольно озадачен. Любая помощь будет принята с благодарностью. Спасибо !!!