當用戶提交表單時,我使用這個PHP腳本發送我的表單的內容到我的電子郵件,但目前我只能夠得到我的表單的最後兩個字段發送在郵件中(郵件和公司名稱是唯一的兩個工作)我怎樣才能讓整個表單發送電子郵件?PHP的電源表格不發送所有的字段到電子郵件
<form role="form" method='post' action='backend/php_mailer.php'>
<input type="text" name='name' class="form-control" id="yourname" placeholder="Name">
<input type="email" name='email' class="form-control" id="email" placeholder="Email">
<input type="text" name='phone' class="form-control" id="phone" placeholder="Phone">
<input type="text" name='company' class="form-control" id="company" placeholder="Company Name">
<textarea name='message' class="form-control" id="message" rows="6" placeholder="Message"></textarea>
<button type="submit" class="btn btn-primary btn-lg ">SUBMIT</button>
</form>
<?php
if (isset($_POST['email']))
{
$userName = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$company = $_REQUEST['company'] ;
$message = $_REQUEST['message'] ;
mail("[email protected]", $subject,
$message,$company,$userName);
echo "Thank you";
}
?>
你傳入$公司和$用戶名作爲額外的參數,而不是將它們串聯到$消息。 – Kevin
同樣使用$ _POST而不是$ _REQUEST – Yani