<?php
$method = $_SERVER['REQUEST_METHOD'];
//Script Foreach
$c = true;
if ( $method === 'POST' ) {
$project_name = trim($_POST["project_name"]);
$admin_email = "тут почта";
$form_subject = trim($_POST["form_subject"]);
foreach ( $_POST as $key => $value ) {
if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
$message .= "" . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "<td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>";
if ($key == "тип_энергосистемы" || $key == "тип_отопления") {
$message .= "<td style='padding: 10px; border: #e9e9e9 1px solid;'>";
foreach ($value as $key1 => $value1) :
$message .= "$value1, ";
endforeach;
$message .= "</td></tr>";
} else {
$message .= "<td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td></tr>";
}
}
}
} else if ( $method === 'GET' ) {
$project_name = trim($_GET["project_name"]);
$admin_email = trim($_GET["admin_email"]);
$form_subject = trim($_GET["form_subject"]);
foreach ( $_GET as $key => $value ) {
if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
$message .= "
" . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
<td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
<td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
</tr>
";
}
}
}
$message = "<table style='width: 100%;'>$message</table>";
function adopt($text) {
return '=?UTF-8?B?'.Base64_encode($text).'?=';
}
$headers = "MIME-Version: 1.0" . PHP_EOL .
"Content-Type: text/html; charset=utf-8" . PHP_EOL .
'From: Заявка <no-replay@real-brand.ru>' . PHP_EOL .
'Reply-To: '.$admin_email.'' . PHP_EOL;
mail($admin_email, adopt($form_subject), $message, $headers );
echo "<div class='callmsg'>Наш менеджер перезвонит в течении
нескольких минут для уточнения заказа.</div>
";
<table class="table table-hover">
<thead>
<tr>
<th>Длина см</th>
<th>Цена</th>
<th>Штук в упаковке</th>
<th>Количество</th>
</tr>
</thead>
<?php if( have_rows('параметры') ): ?>
<tbody>
<?php while( have_rows('параметры') ): the_row();
// vars
$dlin = get_sub_field('длина');
$cena = get_sub_field('цена');
$sht = get_sub_field('штук');
$colvo = get_sub_field('количество');
?>
<tr>
<?php if( $dlin ): ?>
<td><?php echo $dlin;?></td>
<?php endif; ?>
<?php if( $cena ): ?>
<td><?php echo $cena;?></td>
<?php endif; ?>
<?php if( $sht ): ?>
<td><?php echo $sht;?></td>
<?php endif; ?>
<?php if( $colvo ): ?>
<td><?php echo $colvo;?></td>
<?php endif; ?>
</tr>
<?php endwhile; ?>
</tbody>
<?php endif; ?>
</table>