Возникла проблема - форма с обработчиком работает нормально
все корректно доходит на почту
Но ИНОГДА бывает, что доходят не все данные
В чем может быть проблема?
Для отправки использую phpmailer последний
Форма с валидацией, не заполненную форму не пропускает
Не доходит вторая часть, при чем достаточно редко. Например последний раз не дошли $nameplate $phoneClient $mailClient
как можно
отловить такую ошибку???
код обработчика. на всякий случай
<?php
foreach ($_POST as $k => $v) {
$_POST[$k] = trim($v);
}
$tire = " - ";
$slash = " / ";
$br = "\n";
//получаем класс авто
$carclass = ($_POST['b-type']);
//создаем список ассоциаций
$car = array('standard' => 'Standard ', 'business' => 'Business', 'minivan' => 'Minivan', 'van' => 'Van');
$carclass = "Class: ".$car[$carclass];
//получаем откуда едет
$from = ($_POST['from']);
$fromArray = array ('address' => 'Address', 'airport' => 'Airport', 'trainstation' => 'Trainstation');
$from = "From: ".$fromArray[$from];
// куда едем?
$to = ($_POST['to']);
$toArray = array ('address-to' => 'Address', 'airport-to' => 'Airport', 'trainstation-to' => 'Trainstation');
$to = "To: ".$toArray[$to];
// payment метод
$pay = ($_POST['pay']);
$payArray = array ('card' => 'Credit Card', 'cash' => 'Cash to driver');
$pay = "Way of payment: ".$payArray[$pay];
//названия аеропортов откуда
$fromAir = empty($_POST['air']) ? '' : "Arrival Airport: ".$_POST['air'];
$fromAirArray = array ('Arrival Airport: dme' => 'Arrival Airport: Domodedovo (DME)', 'Arrival Airport: svo' => 'Arrival Airport: Sheremetyevo (SVO)', 'Arrival Airport: vko' => 'Arrival Airport: Vnukovo (VKO)');
$fromAir = $fromAirArray[$fromAir];
//названия аеропортов куда
$toAir = empty($_POST['air-to']) ? '' : "Airport: ".trim($_POST['air-to']);
$toAirArray = array ('Airport: dme' => 'Airport: Domodedovo (DME)', 'Airport: svo' => 'Airport: Sheremetyevo (SVO)', 'Airport: vko' => 'Airport: Vnukovo (VKO)');
$toAir = $toAirArray[$toAir];
//с жд вокзала поезда
$fromTrain = empty($_POST['train']) ? '' : "Arrival Train Station: ".trim($_POST['train']);
$fromTrainArray = array ( 'Arrival Train Station: belorussky' => 'Arrival Train Station: Belorussky',
'Arrival Train Station: kazansky' => 'Arrival Train Station: Kazansky',
'Arrival Train Station: kievsky' => 'Arrival Train Station: Kievsky',
'Arrival Train Station: kursky' => 'Arrival Train Station: Kursky',
'Arrival Train Station: leningradsky' => 'Arrival Train Station: Leningradsky',
'Arrival Train Station: paveletsky' => 'Arrival Train Station: Paveletsky',
'Arrival Train Station: rizsky' => 'Arrival Train Station: Rizsky',
'Arrival Train Station: savelovsky' => 'Arrival Train Station: Savelovsky',
'Arrival Train Station: yaroslavsky' => 'Arrival Train Station: Yaroslavsky');
$fromTrain = $fromTrainArray[$fromTrain].$br;
// на жд вокзал
$toTrain = empty($_POST['train-to']) ? '' : "Train Station: ".trim($_POST['train-to']);
$toTrainArray = array ( 'Train Station: belorussky' => 'Train Station: Belorussky',
'Train Station: kazansky' => 'Train Station: Kazansky',
'Train Station: kievsky' => 'Train Station: Kievsky',
'Train Station: kursky' => 'Train Station: Kursky',
'Train Station: leningradsky' => 'Train Station: Leningradsky',
'Train Station: paveletsky' => 'Train Station: Paveletsky',
'Train Station: rizsky' => 'Train Station: Rizsky',
'Train Station: savelovsky' => 'Train Station: Savelovsky',
'Train Station: yaroslavsky' => 'Train Station: Yaroslavsky');
$toTrain = $toTrainArray[$toTrain];
//получаем Дату
$datep = empty($_POST['from-data']) ? '' : "Date: ".$_POST['from-data'];
//подробности адреса
$fromAdr = empty($_POST['from-adress']) ? '' :" Address: ".$_POST['from-adress'];
$hAdr = empty($_POST['hhf']) ? '' : "Time: ".$_POST['hhf'];
$mAdr = empty($_POST['mmf']) ? '' : ":".$_POST['mmf'].$br;
//подробности аэро
$hAir = empty($_POST['hha']) ? '' : "Time: ".$_POST['hha'];
$mAir = empty($_POST['mma']) ? '' : ":".$_POST['mma'].$br;
$flight = empty($_POST['flightnumber']) ? '' : "Flight number: ".$_POST['flightnumber'].$br;
//подробности поезда
$hTrain = empty($_POST['hht']) ? '' :"Time: ".trim($_POST['hht']);
$mTrain = empty($_POST['mmt']) ? '' :":".trim($_POST['mmt']).$br;
$numTrain = empty($_POST['trainnumber']) ? '' : "Train number: ".trim($_POST['trainnumber']).$br;
$numWagon = empty($_POST['wagonnumber']) ? '' : "Wagon number: ".trim($_POST['wagonnumber']).$br;
// адрес
$toAdr = empty($_POST['adress-to']) ? '' :"Address: ".trim($_POST['adress-to']);
// персональная информация
$phoneClient = empty($_POST['phone-client']) ? '' : "Mobile phone: ".trim($_POST['phone-client']).$br;
$mailMail = $_POST['mail-client']; //мыло для отправки письма клиенту
$mailClient = empty($_POST['mail-client']) ? '' : "E-mail: ".trim($_POST['mail-client']);
//неймпленйт или нейм
if ($from == 'From: Address') {
$nameOrplate = 'Name: ';
}
else {$nameOrplate = 'Nameplate: ';
}
$nameplate = empty($_POST['nameplate']) ? '' : $nameOrplate.trim($_POST['nameplate']).$br;
// инфа по кредитке
$price = "Price: ".trim($_POST['price']);
$addInfo = empty($_POST['add-info']) ? '' : "Additional Info: ".trim($_POST['add-info']);
$cardNum = empty($_POST['b-card-1']) ? '' : "Credit card number: ".trim($_POST['b-card-1']);
$cardNum2 = empty($_POST['b-card-2']) ? '' : "- ".trim($_POST['b-card-2']);
$cardNum3 = empty($_POST['b-card-3']) ? '' : "- ".trim($_POST['b-card-3']);
$cardNum4 = empty($_POST['b-card-4']) ? '' : "- ".trim($_POST['b-card-4']).$br;
$periodVal = empty($_POST['card-month']) ? '' : "Expire Date: " .trim($_POST['card-month']).$slash.trim($_POST['card-year']).$br;
$nameholder = empty($_POST['b-holder']) ? '' : "Card Holder’s Name: ".trim($_POST['b-holder']).$br;
$fromValid = false;
$toValid = false;
$cardValid = false;
$_result = false;
$valid = true; // для регулярок номера и почты
$message = '';
switch($_POST['from']) {
case "address":
if(!!$_POST['from-adress'] && (is_numeric($_POST['hhf']) && $_POST['hhf'] <= 24 && $_POST['hhf'] >= 0)
&& (is_numeric($_POST['mmf']) && $_POST['mmf'] <= 60 && $_POST['mmf'] >= 0))
{
$fromValid = true;
}
break;
case "airport":
if(!!$_POST['air'] && !!$_POST['flightnumber'] && (is_numeric($_POST['hha']) && $_POST['hha'] <= 24 && $_POST['hha'] >= 0)
&& (is_numeric($_POST['mma']) && $_POST['mma'] <= 60 && $_POST['mma'] >= 0))
{
$fromValid = true;
}
break;
case "trainstation":
if(!!$_POST['train'] && !!$_POST['trainnumber'] && !!$_POST['wagonnumber']
&& (is_numeric($_POST['hht']) && $_POST['hht'] <= 24 && $_POST['hht'] >= 0)
&& (is_numeric($_POST['mmt']) && $_POST['mmt'] <= 60 && $_POST['mmt'] >= 0))
{
$fromValid = true;
}
break;
}
switch($_POST['to']) {
case "address-to":
if(!!$_POST['adress-to'])
{
$toValid = true;
}
break;
case "airport-to":
if(!!$_POST['air-to'])
{
$toValid = true;
}
break;
case "trainstation-to":
if(!!$_POST['train-to'])
{
$toValid = true;
}
break;
}
//myValidation
switch($_POST['b-type']) {
case "b-type":
if(!!$_POST['standard'])
{
$toValid = true;
}
break;
case "b-type":
if(!!$_POST['business'])
{
$toValid = true;
}
break;
case "b-type":
if(!!$_POST['minivan'])
{
$toValid = true;
}
break;
case "b-type":
if(!!$_POST['van'])
{
$toValid = true;
}
break;
case "b-type":
if(!!$_POST['select-car'])
{
$toValid = false;
}
break;
}
switch($_POST['pay']) {
case "cash":
$cardValid = true;
break;
case "card":
if(!!$_POST['b-holder'] && !!$_POST['card-month'] && !!$_POST['card-year']
&& !!$_POST['b-card-1'] && !!$_POST['b-card-2'] && !!$_POST['b-card-3'] && !!$_POST['b-card-4'] && !!$_POST['nameplate']
&& (isset($_POST['phone-client']) && preg_match('/^\+[0-9]+/', $_POST['phone-client']))
|| (isset($_POST['mail-client'])
&& preg_match('/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/', $_POST['mail-client'])))
{
$cardValid = true;
}
break;
}
include("orderid.php");
if ($pay == 'Way of payment: Credit Card') {
include("book2.php");
}
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$body = "TAXI BOOKING INFORMATION
**********************************
$numberID
$datep
$carclass
$from
--------------------------
$hAdr$mAdr$fromAdr$fromAir$fromTrain $hAir$mAir$hTrain$mTrain $numTrain$flight $numWagon
$to
--------------------------
$toAdr$toAir$toTrain
$nameplate $phoneClient $mailClient
$pay
$price RUB
$addInfo";
$mail->SetFrom('order@********', '*****');
$mail->AddAddress("*********@gmail.com", "");
$mail->Subject = "*******";
$mail->Body=$body;
$mail->CharSet = "utf-8";
if(!$mail->Send()){
echo "Ошибка отправки письма: " . $mail->ErrorInfo;
}else{
echo "<pre>"; echo var_dump($_POST); echo "</pre>";
}