Why mail.php sends a blank email?

A letter arrives, but only provided one, and the subject of the email.


$name = trim($_POST["name"]);
$phone = trim($_POST["phone"]);

$frm_name = "$name";
$recepient = "to@mail.ru";//mail
$sitename = 'Title';
$subject = "New request from the site \"$sitename\"";

if ($name!=""){
 $message .= "Name: $name <br-->";
if ($phone!=""){
 $message .= "Phone: $phone <br>";

mail($recepient, $subject, $message, "From: $sitename <from@mail.ru>" . "\r\n" . "Reply-To: $email" . "\r\n" . "X-Mailer: PHP/" . phpversion() . "\r\n" . "Content-type: text/plain; charset=\"utf-8\"");</from@mail.ru>

<div class="form">
 <form id="form1" onsubmit="return false" autocomplete="off">
 <input type="hidden" name="form" value="form 1" class="js_form_name">
 <label><input type="text" name="name" value placeholder="Enter your name" class="validate" title="Enter your name"></label>
 <label><input type="tel" name="phone" value placeholder="Enter your phone" class="js_phone" title="Enter your phone"></label>
 <input class="send_button" rel="form1" type="submit" value="Get advice">

 <input class="form_name" type="hidden" name="form_name" value="Get free consultation">
 <input type="hidden" name="action" value="send_form">
 <input type="hidden" name="action_type" value="form_feedback">
July 9th 19 at 13:36
2 answers
July 9th 19 at 13:38
Maybe because both these terms negative?
if ($name!=""){
 $message .= "Name: $name <br>";
if ($phone!=""){
 $message .= "Phone: $phone <br>";
on another website everything comes normal ) - Peter.Oberbrunner84 commented on July 9th 19 at 13:41
only the form is slightly different - Peter.Oberbrunner84 commented on July 9th 19 at 13:44
well, try without the conditions of these to do, look at what comes in these variables) - Arielle commented on July 9th 19 at 13:47
: initially write $message to something and I'm sure the message will come.

p.s. try and use empty($var) instead of != "" - Pedro_Herzog commented on July 9th 19 at 13:50
found the problem why didn't they work nothing ) - Peter.Oberbrunner84 commented on July 9th 19 at 13:53
July 9th 19 at 13:40
the problem was solved, from which he took mail.php in common.js it

type: "POST", \\ here it was not enough :).
url: 'mail.php',

Find more questions by tags HTMLPHP