У меня есть форма с несколькими входами и выбор и опция, когда пользователь выбирает значение в опции выбора и (да или нет), открывает с помощью jQuery поля, которые необходимо заполнить, чтобы мы получили ситуацию, которую пользователь не можетНе заполняйте всю форму только тем, что ему нужно, и некоторые входные данные остаются пустыми, но я получаю неопределенную ошибку индекса для полей, которые остаются пустыми.
Вопрос в том, как избежать этой ошибки.
Я не знаю, что я должен был попробовать
if (isset($_POST['submit'])) {
$platform = json_encode($_POST['platform']);
$advertising_history = $_POST['advertising_history'];
$advertising_external = $_POST['advertising_external'];
$period_of_time_office = $_POST['period_of_time_office'];
$price_satisfaction_office = $_POST['price_satisfaction_office'];
$service_satisfaction_office = $_POST['service_satisfaction_office'];
$effectiveness_advertising_office =
$_POST['effectiveness_advertising_office'];
$advertising_price_range = $_POST['advertising_price_range'];
$effectiveness_advertising = $_POST['effectiveness_advertising'];
$outweb_advertising = $_POST['outweb_advertising'];
$outweb_location = $_POST['outweb_location'];
$outweb_effectiveness = $_POST['outweb_effectiveness'];
$valid = true;
if ($valid) {
try {
$pdo = DB();
$stmt = $pdo->prepare("INSERT INTO client_form_5(
client_id,
advertising_history,
advertising_external,
period_of_time_office,
price_satisfaction_office,
service_satisfaction_office,
effectiveness_advertising_office,
platform,
advertising_price_range,
effectiveness_advertising,
outweb_advertising,
outweb_location,
outweb_effectiveness
)
VALUES (
:client_id,
:advertising_history,
:advertising_external,
:period_of_time_office,
:price_satisfaction_office,
:service_satisfaction_office,
:effectiveness_advertising_office,
:platform,
:advertising_price_range,
:effectiveness_advertising,
:outweb_advertising,
:outweb_location,
:outweb_effectiveness
)");
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("advertising_history", $advertising_history,
PDO::PARAM_STR);
$stmt->bindParam("advertising_external", $advertising_external,
PDO::PARAM_STR);
$stmt->bindParam("period_of_time_office", $period_of_time_office,
PDO::PARAM_STR);
$stmt->bindParam("price_satisfaction_office", $price_satisfaction_office,
PDO::PARAM_STR);
$stmt->bindParam("service_satisfaction_office",
$service_satisfaction_office, PDO::PARAM_STR);
$stmt->bindParam("effectiveness_advertising_office",
$effectiveness_advertising_office, PDO::PARAM_STR);
$stmt->bindParam("platform", $platform, PDO::PARAM_STR);
$stmt->bindParam("advertising_price_range", $advertising_price_range,
PDO::PARAM_STR);
$stmt->bindParam("effectiveness_advertising", $effectiveness_advertising,
PDO::PARAM_STR);
$stmt->bindParam("outweb_advertising", $outweb_advertising,
PDO::PARAM_STR);
$stmt->bindParam("outweb_location", $outweb_location, PDO::PARAM_STR);
$stmt->bindParam("outweb_effectiveness", $outweb_effectiveness,
PDO::PARAM_STR);
$stmt->execute();
} catch (PDOException $e) {
exit($e->getMessage());
}
}
}