我是一個PHP noob,所以我不知道在我的消息變量中寫什麼。我需要將表單中的數據發送到電子郵件。我得到了一個textarea,2個輸入(姓名,電子郵件)。希望將來自輸入的文本發送到我的電子郵件。下面的代碼我有:不知道在我的消息變量中寫什麼?
<?
if((isset($_POST['name'])&&$_POST['name']!="") && (isset($_POST['phone'])&&$_POST['phone']!="")){
$to = '[email protected]';
$subject = 'Обратный звонок';
$message;
$headers = "Content-type: text/html; charset=utf-8 \r\n";
$headers .= "From: Отправитель <[email protected]>\r\n";
mail($to, $subject, $message, $headers);
}
?>
<form action="send.php" class="postcard" method="post">
<span>Your message:</span>
<textarea type="text" value="" required></textarea>
<div id="stripe1"></div>
<div id="stripe2"></div>
<img src="./images/Seal_of_the_United_States_Department_of_the_Post_Office.svg. png" alt="Oops" id="seal" />
<img src="./images/stamp.jpg" alt="Stamp" id="stamp" />
<div class="inputs">
<div class="inputs" id="input1"><label for="to" type="text" id="to">to: </label> <input type="text" value=" Me" readonly><div id="stripe3"></div></div>
<div class="inputs" id="input2"><label for="from" type="text" id="from">from: </label> <input type="text" id="input2"><div id="stripe3"></div></div>
<div class="inputs" id="input3"><label for="email" type="text" id="email">email: </label> <input type="text" id="input3"><div id="stripe3"></div></div>
<button type="button" class="btn btn-primary" id="send_button">Send</button>
</form>
[Here](http://php.net/manual/en/tutorial.forms.php)。 – Script47
btw,你可以用if(!empty($ _ POST ['name'])替換if((isset($ _ POST ['name'])&& $ _ POST ['name']!=「」))! –
使用'empty'時,在您的驗證中添加'trim'。 – Script47