M
M
Maxim Gerasimenko2018-02-21 19:24:28
PHP
Maxim Gerasimenko, 2018-02-21 19:24:28

How to add a title to a contact form?

Good day everyone! There is a feedback form:

<?php
    $back = "<p><a href=\"javascript: history.back()\">Вернуться назад</a></p>";
   header('Refresh: 2; url=https://www.site.ru/');
    if(!empty($_POST['name']) and !empty($_POST['phone']) and !empty($_POST['mail']) and !empty($_POST['message'])){
        $name = trim(strip_tags($_POST['name']));
        $phone = trim(strip_tags($_POST['phone']));
        $mail = trim(strip_tags($_POST['mail']));
        $message = trim(strip_tags($_POST['message']));
       
        mail('[email protected]', 'Письмо с адрес_вашего_сайта', 'Вам написал: '.$name.'<br />Его номер: '.$phone.'<br />Его почта: '.$mail.'<br />Его сообщение: '.$message,"Content-type:text/html;charset=utf-8");
       
        echo "<p style='color:black;font-size:35px;text-align:center;margin-top: 20%;'>Ваше сообщение успешно отправлено!</p><Br><p style='color:black;font-size:35px;text-align:center;'>Наш менеджер свяжется с Вами в тчение 10 минут</p>.";
       
        exit;
    }
    else {
        echo "Для отправки сообщения заполните все поля! $back";
        exit;
    }

Everything is working. But how to add headers to headers so that you can specify your subject line and the sender's E-mail? And now the E-mail comes from the mail that was indicated in the application form.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-02-21
@Alex1237

To work with mail, I recommend using PHPMailer , this will make it easier to work with mail, as well as help to prevent direct hit of your letters in spam. There is also a good article about this thing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question