我正在嘗試製作一個簡單的php表單郵件。
所有IM後 有一個電子郵件看起來如何將自定義字段添加到php電子郵件腳本中
Name: joe blogs
Email: [email protected]
Message: anything.
Answer 1: Red
Answer 2: green
Answer 3: Blue
在下面的例子中我已刪除了我的電子郵件地址... 問題是我填寫字段並點擊提交按鈕,我得到我的說消息發送,但沒有電子郵件。 它一直工作正常,直到我添加$ questX字段,然後停止工作。但是我發現$ name文件沒有區別。所以我很困惑。
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$quest = $_REQUEST['quest'] ;
$questb = $_REQUEST['questb'] ;
$questc = $_REQUEST['questc'] ;
$subject = "Competition Entry" ;
$message = $_REQUEST['message'] ;
mail("[email protected]", $subject, "Name:" . $name, "From:" . $email, "Answer 1:" .
$quest, "Answer 2:" . $questb, "Answer 3:" . $questc, $message);
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='win-a-deck2.php'>
<label for='name'>Name:</label><input name='name' type='text' placeholder='Enter your fullname'><br>
<label for='email'>Email:</label><input name='email' type='text'><br>
<label for='message'>Message:</label><br>
<input name='message' type='text'><br>
<label for='quest'>Question 1:</label><input name='quest' type='text' placeholder='Answer to Question 1'><br>
<label for='questb'>Question 2:</label><input name='questb' type='text' placeholder='Answer to Question 2'><br>
<label for='questc'>Question 3:</label><input name='questc' type='text' placeholder='Answer to Question 3'><br>
<input type='submit'>
</form>";
}
?>
你有$ questc,$ message。你需要它是$ questc。 $消息,因爲它是給郵件函數4個參數,你只需要3加上第四個參數應該是一個頭設置 –