Answer the question
In order to leave comments, you need to log in
Why are only selected parameters passed through the form?
Hello! I have a standard form to order a call with the parameters name, phone, email, message. The whole catch is that the data of the name and phone fields reach, but email and message do not. What could be the reason? The form itself:
<form name="sentMessage" class="form form-register1" id="contactForm" >
<div class="control-group">
<div class="controls">
<input type="text" class="form-control" onblur='if(this.value=="") this.placeholder="Ваше имя"' onfocus='if(this.value=="Ваше имя") this.value=""' placeholder="Ваше имя" id="name" required data-validation-required-message="Пожалуйста укажите ваше имя" />
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="tel" class="form-control" onblur='if(this.value=="") this.placeholder="Телефон"' onfocus='if(this.value=="Телефон") this.value=""' placeholder="Телефон" id="phone" required data-validation-required-message="Пожалуйста, укажите номер телефона" />
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="email" class="form-control" onblur='if(this.value=="") this.placeholder="Email"' onfocus='if(this.value=="Email") this.value=""' placeholder="[email protected]" required name="email" id="email" required data-validation-required-message="Пожалуйста, укажите ваш e-mail">
</div>
</div>
<div class="control-group">
<div class="controls">
<textarea class="form-control" onblur='if(this.value=="") this.placeholder="Ваше сообщение"' onfocus='if(this.value=="Ваше сообщение") this.value=""' placeholder="Введите сообщение..." id="message" name="message" required data-validation-required-message="Пожалуйста, введите ваш вопрос" /></textarea>
</div>
</div>
<div id="success"> </div> <!-- For success/fail messages -->
<button type="submit" class="ring-btn-yellow">Отправить</button>
</form>
if(empty($_POST['name']) || empty($_POST['phone']))
{
echo "Не переданы данные!";
return false;
}
$name = $_POST['name'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$email = $_POST['email'];
$to = '[email protected]'; // put your email
$email_subject = "Вам отправлена форма - Перезвоните мне: $name";
$email_body = "Заполнена форма \"Перезвоните мне\". \n\n".
"Данные отправителя:\n\nИмя: $name ".
"Телефон: $phone \n".
"Email: $email \n".
"Сообщение: $message";
$headers = "From: [email protected]\n";
$headers .= "Reply-To:";
mail($to,$email_subject,$email_body,$headers);
return true;
Answer the question
In order to leave comments, you need to log in
Judging by the form, on the contrary, you should not receive the "phone" field, since name="phone" is not filled in the input id="phone". But this is if you send via post. Which is unlikely, because for sending you need not <button type="submit"> but <input type="submit">
If you send via AJAX (without page transition), you also need to look in the JS script, which fields it is transmits.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question