[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Не работает скрипт на PHP
noob12321
Всем привет. Есть вот такой скрипт - <?php

ini_set('error_reporting', 0);
ini_set('display_errors', 0);

define( 'DB_USER', 'eklips' );
define( 'DB_PASS', 'eklips123' );
define( 'conString', 'mysql:host=localhost;dbname=eklips' );

$pdo = '';

try {
$pdoz = new PDO( conString, DB_USER, DB_PASS );
$pdoz->exec( 'SET NAMES utf8');
$msg = 'Соединение работает!';
} catch ( PDOException $e ) {
$msg = 'Соединение не работает!';
}

$pdo = $pdoz;

$container = '';
if (!empty( $_REQUEST['f_width'] ) && !empty( $_REQUEST['f_profile'] ) && !empty( $_REQUEST['f_diametr'] )) {
$container = '<div class="container"><div class="row">';

$sql = 'SELECT * FROM products WHERE status=1 ';

if(!empty($_REQUEST['f_width'])) {
$width = "'".implode( "','", $_REQUEST['f_width'])."'";
$sql .= 'AND width IN ('.$width.') ';
}
if(!empty($_REQUEST['f_profile'])) {
$profile = "'".implode( "','", $_REQUEST['f_profile'])."'";
$sql .= 'AND profile IN ('.$profile.') ';
}
if(!empty($_REQUEST['f_diametr'])) {
$radius = "'".implode( "','", $_REQUEST['f_diametr'])."'";
$sql .= 'AND radius IN ('.$radius.') ';
}

if(!empty($_REQUEST['f_brand'])) {
$brand = "'".implode( "','", $_REQUEST['f_brand'])."'";
$sql .= 'AND brand IN ('.$brand.') ';
}

if(!empty($_REQUEST['f_season'])) {
$seasons = [];
foreach ($_REQUEST['f_season'] as $season) {
if ($season === 'summer') {
$thorns = 0;
$seasons[] = ' Летняя';
} elseif ($season === 'winters') {
$thorns = 1;
$seasons[] = ' Зимняя';
} elseif ($season === 'winter') {
$thorns = 0;
$seasons[] = ' Зимняя';
}
}
$seasons = "'".implode( "','", $seasons)."'";
$sql .= 'AND season IN ('.$seasons.') ';
if (isset($thorns) && $thorns === 1) {
$sql .= 'AND thorns = 1 ';
}
}

$stmt = $pdo->prepare(trim($sql));
$stmt->execute();
$result_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($result_data === false) {
$pdo_error = $stmt->errorInfo();
}

$count = 0;
if (!empty($result_data)) {
foreach ( $result_data as $product ) {
$container .= '
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-12">
<div class="item">
<div class="item-h">
<a data-fancybox="gallery" href=' . $product['img_s'] . '>
<img src=' . $product['img_o'] . ' alt=' . $product['brand'] . ' ' . $product['name'] . '>
</a>
<p class="item-h-name">' . $product['brand'] . ' ' . $product['name'] . '</p>
</div>
<div class="item-d">
<ul class="list-desc">
<li><span>Сезон:</span><span class="text-right">' . $product['season'] . '</span></li>
<li><span>Диаметр:</span><span class="text-right">' . $product['radius'] . '</span></li>
<li><span>Профиль:</span><span class="text-right">' . $product['profile'] . '</span></li>
<li><span>Ширина:</span><span class="text-right">' . $product['width'] . '</span></li>
</ul>
</div>
</div>
</div>';
++ $count;
if ( $count % 3 == 0 ) {
$container .= '<div class="clearfix visible-md hidden-lg hidden-sm"></div>';
}
if ( $count % 4 == 0 ) {
$container .= '<div class="clearfix visible-lg hidden-md hidden-sm"></div>';
}
}
} else {
$container .= '<div class="col-md-10">
<h2 class="error-text text-center">Не найдено результатов по данным параметрам!</h2>
<h3 class="error-text text-center">Выберите другие параметры.</h3>
</div>';
}

$container .= '</div></div>';
}
if (empty($_REQUEST['f_width'])) {
$error[] = 'Вы не выбрали ширину!';
}
if (empty($_REQUEST['f_profile'])) {
$error[] = 'Вы не выбрали профиль!';
}
if (empty($_REQUEST['f_diametr'])) {
$error[] = 'Вы не выбрали диаметр!';
}

if (!empty($error)) {
$error_msg = implode( ' ', $error);
$container = '<div class="container"><div class="row">';
$container .= '<div class="col-md-10">
<h3 class="error-text text-center">'.$error_msg.'</h3>
</div>';
$container .= '</div></div>';
}

$result = ['result' => $container, 'data' => $result_data];
echo json_encode( $result );

К нему еще идет скрипт формы -

<?php
/*
If you see this text in your browser, PHP is not configured correctly on this hosting provider.
Contact your hosting provider regarding PHP configuration for your site.

PHP file generated by Adobe Muse CC 2017.0.0.363
*/
ini_set('error_reporting', 0);
ini_set('display_errors', 0);

require_once('form_process.php');

$form = array(
'subject' => 'Отправка Подбор шин сайт',
'heading' => 'Отправка новой формы',
'success_redirect' => 'zakazshin.html',
'resources' => array(
'checkbox_checked' => 'Отмечено',
'checkbox_unchecked' => 'Флажок не установлен',
'submitted_from' => 'Формы, отправленные с веб-сайта: %s',
'submitted_by' => 'IP-адрес посетителя: %s',
'too_many_submissions' => 'Недопустимо высокое количество отправок с этого IP-адреса за последнее время',
'failed_to_send_email' => 'Не удалось отправить сообщение эл. почты',
'invalid_reCAPTCHA_private_key' => 'Недействительный закрытый ключ reCAPTCHA.',
'invalid_reCAPTCHA2_private_key' => 'Недействительный закрытый ключ reCAPTCHA 2.0.',
'invalid_reCAPTCHA2_server_response' => 'Недействительный ответ сервера reCAPTCHA 2.0.',
'invalid_field_type' => 'Неизвестный тип поля \'%s\'.',
'invalid_form_config' => 'Недопустимая конфигурация поля \"%s\".',
'unknown_method' => 'Неизвестный метод запроса сервера'
),
'email' => array(
'from' => 'manager@eklips.kz',
'to' => 'manager@eklips.kz'
),
'fields' => array(
'custom_U82659' => array(
'order' => 55,
'type' => 'string',
'label' => 'Имя',
'required' => true,
'errors' => array(
'required' => 'Поле \'Имя\' не может быть пустым.'
)
),
'custom_U82600' => array(
'order' => 56,
'type' => 'string',
'label' => 'Сотовый телефон',
'required' => true,
'errors' => array(
'required' => 'Поле \'Сотовый телефон\' не может быть пустым.'
)
),
'custom_U82608' => array(
'order' => 1,
'type' => 'checkbox',
'label' => '145',
'required' => false,
'errors' => array(
)
),
'custom_U82663' => array(
'order' => 53,
'type' => 'string',
'label' => 'Пользовательский текст',
'required' => false,
'errors' => array(
)
),
'custom_U82692' => array(
'order' => 54,
'type' => 'string',
'label' => 'Пользовательский текст',
'required' => false,
'errors' => array(
)
),
'custom_U82642' => array(
'order' => 2,
'type' => 'checkbox',
'label' => '155',
'required' => false,
'errors' => array(
)
),
'custom_U82688' => array(
'order' => 3,
'type' => 'checkbox',
'label' => '165',
'required' => false,
'errors' => array(
)
),
'custom_U82630' => array(
'order' => 4,
'type' => 'checkbox',
'label' => '175',
'required' => false,
'errors' => array(
)
),
'custom_U82684' => array(
'order' => 5,
'type' => 'checkbox',
'label' => '185',
'required' => false,
'errors' => array(
)
),
'custom_U82696' => array(
'order' => 6,
'type' => 'checkbox',
'label' => '195',
'required' => false,
'errors' => array(
)
),
'custom_U82667' => array(
'order' => 10,
'type' => 'checkbox',
'label' => '235',
'required' => false,
'errors' => array(
)
),
'custom_U82651' => array(
'order' => 11,
'type' => 'checkbox',
'label' => '245',
'required' => false,
'errors' => array(
)
),
'custom_U82671' => array(
'order' => 8,
'type' => 'checkbox',
'label' => '215',
'required' => false,
'errors' => array(
)
),
'custom_U82604' => array(
'order' => 7,
'type' => 'checkbox',
'label' => '205',
'required' => false,
'errors' => array(
)
),
'custom_U82638' => array(
'order' => 9,
'type' => 'checkbox',
'label' => '225',
'required' => false,
'errors' => array(
)
),
'custom_U82621' => array(
'order' => 12,
'type' => 'checkbox',
'label' => '255',
'required' => false,
'errors' => array(
)
),
'custom_U82592' => array(
'order' => 13,
'type' => 'checkbox',
'label' => '265',
'required' => false,
'errors' => array(
)
),
'custom_U82613' => array(
'order' => 14,
'type' => 'checkbox',
'label' => '275',
'required' => false,
'errors' => array(
)
),
'custom_U82680' => array(
'order' => 17,
'type' => 'checkbox',
'label' => '305',
'required' => false,
'errors' => array(
)
),
'custom_U82634' => array(
'order' => 19,
'type' => 'checkbox',
'label' => '325',
'required' => false,
'errors' => array(
)
),
'custom_U82625' => array(
'order' => 20,
'type' => 'checkbox',
'label' => '335',
'required' => false,
'errors' => array(
)
),
'custom_U82676' => array(
'order' => 15,
'type' => 'checkbox',
'label' => '285',
'required' => false,
'errors' => array(
)
),
'custom_U82617' => array(
'order' => 16,
'type' => 'checkbox',
'label' => '295',
'required' => false,
'errors' => array(
)
),
'custom_U82655' => array(
'order' => 18,
'type' => 'checkbox',
'label' => '315',
'required' => false,
'errors' => array(
)
),
'custom_U92057' => array(
'order' => 24,
'type' => 'checkbox',
'label' => '45',
'required' => false,
'errors' => array(
)
),
'custom_U92069' => array(
'order' => 26,
'type' => 'checkbox',
'label' => '55',
'required' => false,
'errors' => array(
)
),
'custom_U92081' => array(
'order' => 25,
'type' => 'checkbox',
'label' => '50',
'required' => false,
'errors' => array(
)
),
'custom_U92167' => array(
'order' => 27,
'type' => 'checkbox',
'label' => '60`',
'required' => false,
'errors' => array(
)
),
'custom_U92179' => array(
'order' => 28,
'type' => 'checkbox',
'label' => '65',
'required' => false,
'errors' => array(
)
),
'custom_U92191' => array(
'order' => 29,
'type' => 'checkbox',
'label' => '70',
'required' => false,
'errors' => array(
)
),
'custom_U92203' => array(
'order' => 30,
'type' => 'checkbox',
'label' => '75',
'required' => false,
'errors' => array(
)
),
'custom_U92215' => array(
'order' => 31,
'type' => 'checkbox',
'label' => '80',
'required' => false,
'errors' => array(
)
),
'custom_U92227' => array(
'order' => 32,
'type' => 'checkbox',
'label' => '85',
'required' => false,
'errors' => array(
)
),
'custom_U92242' => array(
'order' => 33,
'type' => 'checkbox',
'label' => '90',
'required' => false,
'errors' => array(
)
),
'custom_U92254' => array(
'order' => 35,
'type' => 'checkbox',
'label' => 'R13',
'required' => false,
'errors' => array(
)
),
'custom_U92266' => array(
'order' => 36,
'type' => 'checkbox',
'label' => 'R14',
'required' => false,
'errors' => array(
)
),
'custom_U92278' => array(
'order' => 37,
'type' => 'checkbox',
'label' => 'R15',
'required' => false,
'errors' => array(
)
),
'custom_U92290' => array(
'order' => 38,
'type' => 'checkbox',
'label' => 'R16',
'required' => false,
'errors' => array(
)
),
'custom_U92302' => array(
'order' => 39,
'type' => 'checkbox',
'label' => 'R17',
'required' => false,
'errors' => array(
)
),
'custom_U92314' => array(
'order' => 40,
'type' => 'checkbox',
'label' => 'R18',
'required' => false,
'errors' => array(
)
),
'custom_U92326' => array(
'order' => 41,
'type' => 'checkbox',
'label' => 'R19',
'required' => false,
'errors' => array(
)
),
'custom_U92338' => array(
'order' => 42,
'type' => 'checkbox',
'label' => 'R20',
'required' => false,
'errors' => array(
)
),
'custom_U92350' => array(
'order' => 43,
'type' => 'checkbox',
'label' => 'R21',
'required' => false,
'errors' => array(
)
),
'custom_U92362' => array(
'order' => 45,
'type' => 'checkbox',
'label' => 'Bridgestone',
'required' => false,
'errors' => array(
)
),
'custom_U92374' => array(
'order' => 46,
'type' => 'checkbox',
'label' => 'Cordiant',
'required' => false,
'errors' => array(
)
),
'custom_U92386' => array(
'order' => 47,
'type' => 'checkbox',
'label' => 'Hankook',
'required' => false,
'errors' => array(
)
),
'custom_U92398' => array(
'order' => 48,
'type' => 'checkbox',
'label' => 'Maxxis',
'required' => false,
'errors' => array(
)
),
'custom_U92410' => array(
'order' => 49,
'type' => 'checkbox',
'label' => 'Nokian',
'required' => false,
'errors' => array(
)
),
'custom_U92422' => array(
'order' => 52,
'type' => 'checkbox',
'label' => 'Зимние
без шипов',
'required' => false,
'errors' => array(
)
),
'custom_U92434' => array(
'order' => 51,
'type' => 'checkbox',
'label' => 'Зимние
с шипами',
'required' => false,
'errors' => array(
)
),
'custom_U92446' => array(
'order' => 50,
'type' => 'checkbox',
'label' => 'Летние',
'required' => false,
'errors' => array(
)
),
'custom_U138761' => array(
'order' => 34,
'type' => 'checkbox',
'label' => 'R12',
'required' => false,
'errors' => array(
)
),
'custom_U138827' => array(
'order' => 44,
'type' => 'checkbox',
'label' => 'R22',
'required' => false,
'errors' => array(
)
),
'custom_U138887' => array(
'order' => 21,
'type' => 'checkbox',
'label' => '25',
'required' => false,
'errors' => array(
)
),
'custom_U138947' => array(
'order' => 22,
'type' => 'checkbox',
'label' => '35',
'required' => false,
'errors' => array(
)
),
'custom_U139007' => array(
'order' => 23,
'type' => 'checkbox',
'label' => '45',
'required' => false,
'errors' => array(
)
)
)
);

process_form($form);
?>

Они не работают (в письме на указанную почту, даже если что то выбрал - пишет, флажок не установлен). Подскажите, что в коде не так? Спасибо.
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.