Answer the question
In order to leave comments, you need to log in
Adding select in php mandrel form?
I have not worked with php before, so please do not judge for simplicity. There is:
<form id="form">
<input type="text" name="name" placeholder="Ваше имя" required /><br />
<input type="text" name="phone" placeholder="Ваш телефон" required /><br />
<select>
<option value="0">Ващ выбор</option>
<option value="1">Выбор 1</option>
<option value="2">Выбор 2</option>
</select>
<button>Отправить</button>
</form>
$(document).ready(function() {
$("#form").submit(function() {
$.ajax({
type: "POST",
url: "mail.php",
data: $(this).serialize()
}).done(function() {
$(this).find("input").val(""); // вот здесьь нужно еще что-то добавлять ?
alert("Спасибо за заявку! Скоро мы с вами свяжемся.");
$("#form").trigger("reset");
});
return false;
});
});
<?php
$recepient = "[email protected]";
$sitename = "Название сайта";
$name = trim($_POST["name"]);
$phone = trim($_POST["phone"]);
$text = trim($_POST["text"]);
$select = trim($_POST[]); // что вписывать сюда ?
$message = "Имя: $name \nТелефон: $phone \nТекст: $text \nВыбор: $select";
$pagetitle = "Новая заявка с сайта \"$sitename\"";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");
Answer the question
In order to leave comments, you need to log in
<select name="select_value">
<option value="0">Ващ выбор</option>
<option value="1">Выбор 1</option>
<option value="2">Выбор 2</option>
</select>
Add select to at least some value of the name attribute and substitute it in $_POST[]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question