Answer the question
In order to leave comments, you need to log in
How to create send the data of an existing form on the site to e-mail?
IMPORTANT! The site is written on a local server.
The site has a feedback form block:
<div class="modal-content">
<span class="close">×</span>
<div class="mailform">
<form action="./send.php" method="POST">
<div class="row">
<div class="col-25">
<label for="fio">Ф.И.О.</label>
</div>
<div class="col-75">
<input type="text" id="fio" name="fio" placeholder="Ваше имя.." required>
</div>
</div>
<div class="row">
<div class="col-25">
<label for="email">Email</label>
</div>
<div class="col-75">
<input type="text" id="email" name="email" placeholder="Ваша электронная почта.." required>
</div>
</div>
<div class="row">
<div class="col-25">
<label for="telephone">Телефон</label>
</div>
<div class="col-75">
<input type="text" id="telephone" name="telephone" placeholder="Ваш контактный телефон.." required>
</div>
</div>
<div class="row">
<div class="col-25">
<label for="city">Город</label>
</div>
<div class="col-75">
<input type="text" id="city" name="city" placeholder="Откуда вы?..">
</div>
</div>
<div class="row">
<div class="col-25">
<label for="subject">Сообщение</label>
</div>
<div class="col-75">
<textarea id="subject" name="subject" placeholder="Напишите здесь Ваш запрос или сообщение.." style="height:200px" required></textarea>
</div>
</div>
<div class="row">
<input type="submit" value="Отправить">
</div>
</form>
</div>
</div>
<?php
$fio = $_POST['fio'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$city = $_POST['city'];
$subject = $_POST['subject'];
$fio = htmlspecialchars($fio);
$email = htmlspecialchars($email);
$telephone = htmlspecialchars($telephone);
$city = htmlspecialchars($city);
$subject = htmlspecialchars($subject);
$fio = urldecode($fio);
$email = urldecode($email);
$telephone = urldecode($telephone);
$city = urldecode($city);
$subject = urldecode($subject);
$fio = trim($fio);
$email = trim($email);
$telephone = trim($telephone);
$city = trim($city);
$subject = trim($subject);
echo $fio;
echo "<br>";
echo $email;
mail("[email protected]", "Заявка с сайта", "Отправитель: ".$fio". Email: ".$email". Телефон: ".$telephone". Город: ".$city". Сообщение: ".$subject,"From: [email protected] \r\n");
if mail("[email protected]", "Заявка с сайта", "Отправитель: ".$fio". Email: ".$email". Телефон: ".$telephone". Город: ".$city". Сообщение: ".$subject,"From: [email protected] \r\n"))
{
echo "Сообщение успешно отправлено";
} else {
echo "Ошибка при отправке сообщения";
}
}?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question