Hello, there is a PHP form, it works well, but sends me blank lines, but they look like this: Name: Patronymic: Email: Message:

I just discovered that values ​​are not recorded in variables at all, what could be the problem?

<?php if(isset($_POST["name"]) && isset($_POST["second"]) && isset($_POST["email"]) && isset($_POST["message"])) { $name = $_POST["name"]; $second = $_POST["second"]; $email = $_POST["email"]; $message = $_POST["message"]; } $to = "ololololololo@gmail.com"; $subject = "A new message from website!"; $body = "Имя:" . $name ."\n" . "Отчество:" . $second ."\n" . "Имейл: " .$email ."\n" . "Сообщение:" . $message; $header = "From :" .$email; if (mail($to, $subject, $body, $header)) { echo "Success"; } else { echo "Fail"; } ?> 
 <form method="POST" id="form" action='main.php' name="form"> <div class="input-1"> <label for="">Имя:</label> <input type="text" placeholder="Иван" autofocus="autofocus" required="required" name="name" id="name"> </div> <div class="input-1"> <label for="">Отчество:</label> <input type="text" placeholder="Иванович" required="required" name="second" id="second"> </div> <div class="email"> <label for="email">Email:</label> </div> <input type="email" placeholder="example@mail.ru" required="required" name="email" id="email"> <div class="message"> <label for="area">Сообщение:</label> </div> <textarea cols="30" rows="10" placeholder="Введите сообщение..." required="required" name="message" id="message"></textarea> <div class="sbm"> <input type="submit" name="submit" value="Отправить"> </div> </form> 

Comrades, I ask for help!

    2 answers 2

    Everything, I solved the problem myself, just wrote down the values ​​in variables with an additional dubbing, only without isset.

      UPD: as I expected, the problem is in your server, since everything works with exim4. If you are hosted on a hosting - write to tech support. If you have your own VDS / VPS, then install a mail server.

      At least do this:

       <?php if(isset($_POST["name"]) && isset($_POST["second"]) && isset($_POST["email"]) && isset($_POST["message"])) { $name = $_POST["name"]; $second = $_POST["second"]; $email = $_POST["email"]; $message = $_POST["message"]; $to = "ololololololo@gmail.com"; $subject = "A new message from website!"; $body = "Имя:" . $name ."\n" . "Отчество:" . $second ."\n" . "Имейл: " .$email ."\n" . "Сообщение:" . $message; $header = "From :" .$email; if (mail($to, $subject, $body, $header)) { echo "Success"; } else { echo "Fail"; } } else { echo 'Поля пусты.'; } ?> 

      Maybe you for some reason do not send data? But I feel that you have something wrong with mail ().

      • On the hosting function works fine. I just discovered that it turns out that values ​​are not recorded at all in a variable. What could be the problem? - Alexey Krasnov