Jump to content
  • 0

Скрипт обратной связи


makissm21
 Share

Question

Добрый день, прошу у вас помощи, на скрине http://shot.qip.ru/00eaLf-3EBATV0HL/ отметил красным, что бы в место этого указывался емаил $email отправителя.

Помогите реализовать это, заранее благодарен за вашу помощь

<?php
$post = (!empty($_POST)) ? true : false;
if($post)
{
$email = trim($_POST["email"]);
$name = htmlspecialchars($_POST["name"]);
$email = htmlspecialchars($_POST["email"]);
$tel = htmlspecialchars($_POST["tel"]);
$error = "";
if(!$name)
{
$error .= "Пожалуйста введите ваше имя<br />";
}

// Check email
function ValidateEmail($value)
{
$regex = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/";
if($value == "") {
return false;
} else {
$string = preg_replace($regex, "", $value);
}
return empty($string) ? true : false;
}
if(!$email)
{
$error .= "Пожалуйста введите e-mail<br />";
}
if($email && !ValidateEmail($email))
{
$error .= "Введите корректный e-mail<br />";
}

// Check tel
function ValidateTel($valueTel)
{
$regexTel = "/^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/";
if($valueTel == "") {
return false;
} else {
$string = preg_replace($regexTel, "", $valueTel);
}
return empty($string) ? true : false;
}
if(!$tel)
{
$error .= "Пожалуйста введите телефон<br />";
}
if($tel && !ValidateTel($tel))
{
$error .= "Введите корректный телефон<br />";
}
if(!$error)
{
$to = '89119176117@mail.ru';
$subject = '=?utf-8?B?'.base64_encode('Заявка').'?=';
$headers = 'From: =?UTF-8?B?' . base64_encode($name) . '?= <=?UTF-8?B?' . base64_encode($name) . "?=>\r\n";
$headers .= 'Return-path: <' . $email . ">\r\n";
$headers .= 'Content-type: text/plain; charset=utf-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
$message = "Новый запрос!\n\nИмя: $name\n\nEmail: $email\n\nТелефон: $tel\n\n";
$mail = mail($to, $subject, $message, $headers);

if($mail)
{
echo '<div class="notification_ok2">Большое спасибо за обращение, в течении часа вам обязательно ответят</div>';
}
}
else
{
echo '<div class="notification_error2">'.$error.'</div>';
}
}
?>

Edited by alexriz
Оформляйте код в тег CODE
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

попробуй это не кодировать

$headers = 'From: =?UTF-8?B?' . base64_encode($name) . '?= <=?UTF-8?B?' . base64_encode($name) . "?=>\r\n";

или наоборот. ещё и это закодируй

$headers .= 'Return-path: <' . $email . ">\r\n";

Edited by Николя223
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy