编辑:我的邮件确实已发送,但它不会发送FORM信息,只发送我放置的文本。所以这不是一个电子邮件问题,这是将数据附加到电子邮件的问题。我以前没见过这个问题。
我不是最好的PHP,但我一直关注互联网上的一些指南,只是学习一些PHP。我已经创建了一个HTML格式的表单,我希望在提交后通过电子邮件发送给我。这是我的代码。
我收到了一封电子邮件,但表单输入没有发送给我。有人可以帮助我。我已经尝试过验证我的代码,这一切似乎都是正确的,而且我的逻辑中没有任何缺陷。任何帮助都将受到强烈赞赏。
<?php
//Creating Variables with data obtained from FORM on Previous Page
$firstname = $_POST['FirstName'];
$lastname = $_POST['LastName'];
$date = $_POST['Date'];
$pick_up_time = $_POST['Time'];
$vehicle = $_POST['Fleet'];
$passenger = $_POST['Passengers'];
$l_bags = $_POST['LargeBags'];
$s_bags = $_POST['SmallBags'];
$phone_number = $_POST['PhoneNumber'];
$e_mail = $_POST['eMail'];
$comments = $_POST['Comments'];
//Testing to see if variable is getting created
if ($firstname == "Reiyyan") {
print ("Welcome back, friend!");
}
else {
print ("MISSING DATA");
}
$email_from = 'reiyyan@gmail.com';
$email_subject = "New Message Test";
$email_body = "You got mail, here are the details. \n $firstname \n $lastname \n $date \n $pick_up_time \n $vehicle \n $passenger \n $l_bags \n $s_bags \n $phone_number \n $e_mail \n $comments".;
$to = "reiyyan@gmail.com";
$headers = "From: $email_from \r\n";
//send mail
mail($to,$email_subject,$email_body,$headers);
//done
?>
这是我的HTML表单
<form id="RequestCar" method="post" action="emailForm.php" enctype="text/plain">
First Name: <input type="text" name="FirstName" placeholder="First Name" required/>
Last Name: <input type="text" name="LastName" placeholder="Last Name" required />
<br /><br />
Date: <input type="date" name="Date" placeholder="01/01/2017" required />
Pickup Time: <input type="time" name="Time" placeholder="12:00 PM" required />
<br /><br />
Vehicle:
<select name="Fleet">
<option value="No Preference">No Preference</option>
<option value="LuxurySedan">Luxury Sedan</option>
<option value="SUV">Sub Utility Vehicle (SUV)</option>
<option value="Minivan">Minivan</option>
<option value="Minivan">Stretch Limousine</option>
<option value="Minivan">SUV Limousine</option>
<option value="Minivan">Hummer Limousine</option>
</select>
<br /><br />
# of Passengers: <input type="number" name="Passengers" required min="1" />
# of Large Bags: <input type="number" name="LargeBags" />
# of Small Bags: <input type="number" name="SmallBags" />
<br /><br />
Phone Number: <input type="tel" name="PhoneNumber" required />
eMail: <input type="email" name="eMail" required />
<br /><br />
Additional Comments
<br /><br />
<textarea rows="6" cols="100" name="Comments" form="RequestCar" placeholder="Enter Text Here..."></textarea>
<br /><br />
<input type="submit" value="Submit">
</form>
无论我尝试什么,我都会不断获得&#34; MISSING DATA&#34;。看起来Form并没有将变量传递给php页面。
编辑:这是托管在GoDaddy,LINUX服务器上。
答案 0 :(得分:1)
更改表单操作转到
<form id="RequestCar" method="POST" action="emailForm.php" enctype="text/plain">