我有一個代碼塊,採取一種形式,張貼到同一頁與感謝您的消息,然後繼續發送電子郵件到我的帳戶。格式PHP的時候它張貼和電子郵件
截至目前,它會顯示這樣的郵件結尾:
hello world., Name: Hello World, , Email: [email protected]
這意味着它會消息,名稱,然後電子郵件。
我怎樣才能使它所以它顯示類似的郵件是這樣的..
Name: Hello World
Email: [email protected]
Message: hello world...
這裏是我使用的代碼:
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$subject = $_REQUEST["My Portfolio Website"] ;
$message = $_REQUEST['message'].", Name: ".$name.", Email: ".$email;
mail("[email protected]", $subject, $message, "From:" . $email);
echo "<h1>Thank you for contacting me. I will get back to you ASAP!</h1>";
}else{
//if "email" is not filled out, display the form
echo "<form method='post' action='index.php'>
<input type='text' input name='name' id='name' class='contacttext' placeholder='Your Name' required>
<input type='text' input name='email' id='email' class='contacttext' placeholder='Your Email Address' required>
<textarea name='message' id='message' class='contacttext' placeholder='Your Message' cols='55' rows='5' required></textarea>
<input type='submit' id='submit' class='submitcontacttext' value='Send'>
</form>";
}
?>
而且,目前的主題是不設置自己,這是什麼原因?
用空格HTML輸入轉換爲在PHP下劃線'_',所以你需要'$ _REQUEST [ 「My_Portfolio_Website」]'。要格式化,請使用換行符'\ n' /'\ r \ n' – Sean
您是否嘗試過任何操作?看起來不像。 –