当我上传后在服务器端渲染它时,我收到一封电子邮件,但它是空白的。来自空白的文本是空白ECHO中的$名称是空白的部分。任何想法我能做些什么来完成这项工作?为什么我的PHP脚本发送空白电子邮件?
这里是我的形式:
<form action="survey.php" method="post" name="survey">
<table>`enter code here`
<tr><th colspan="2">Survey</th></tr>
<tr><td>Name:</td><td align="center"><input type="text"
name="name" id="name" /></td></tr>
<tr><td>When was your last visit</td><td
align="center"><select id="long" name="long">
<option value="Select">Please Select</option>
<option value="1-2 days">1-2 days ago</option>
<option value="3-5 days">3-5 days ago</option>
<option value="1-2 weeks">1-2 weeks ago</option>
<option value="3-5 weeks">3-5 weeks ago</option>
<option value="2 months">2 months</option>
<option value="3+months">3+ months </option>
<option value="Never">Never Visited</option>
</select></td></tr>
<tr>
<td>Tell us about your experience?</td><td
align="center"><textarea cols="22" rows="5" id="experience"
name="experience"></textarea></td></tr>
<tr><td>Will you come back
to visit again?</td><td align="center"><input type="checkbox"
id="visit" name="visit" value="Yes" />Yes<input type="checkbox"
id="visit" name="visit" value="No" />No</td></tr>
<tr><td colspan="2"><input type="submit" value="Submit" /><input
type="reset" value="Reset" /></td></tr>
</table>
</form>
我的PHP代码
<?php
/* subject and e-mail variables*/
$emailSubject = $name;
$webMaster = '[email protected]';
/* Gathering data Variables */
$nameField = $_POST['name'];
$selectField = $_POST['long'];
$commentsField = $_POST['experience'];
$visitField = $_POST['visit'];
$body = <<<EOD
<br><hr><br>
Name: $name<br>
Date of last visit: $long<br>
Expierence: $experience<br>
Visit again: $visit<br>
EOD;
$headers = "From: $name\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail ($webMaster, $emailSubject, $body, $headers);
/* Results rendered as HTML */
/* When changing the fields please leave the <<<EOD and the EOD;
If they are deleted this form will not work */
$theResults = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/>
<title>Coupon</title>
<script language="javascript" type="text/javascript">
var d=datetime.getDate()
var datetime=new Date()
var day=datetime.getDay()
var month=datetime.getMonth()
var year=datetime.getYear()
if (year < 1000)
year+=1900
var days=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var months=new
Array("January","February","March","April","May","June","July","August","September","Octomber","November","December")
</script>
<style type="text/css">
#frame {
position:absolute;
top:16px;
left:124px;
height:355px;
width:480px;
border:2px dotted red;
font:"Trebuchet MS", Veranda, sans-serif;
color:red;
padding: 10px;
}
</style>
</head>
<body>
<div id="frame">
<h3 align="center">Thanks for Participating in our survey,
$name!</h3>
<p align="center">Here is a special offer for you:</p>
<h2 align="center">Free Egg Roll!</h2>
<p align="center">Please print out this coupon to recieve a free
egg roll with the purchase of a meal.</p>
<p> </p>
<p> </p>
<p style="font-size:x-small">Limit one coupon per visit. Coupon
valid at all locations. Coupon will expire one month after date on
coupon. Cannot be combined with other offers or promotions. Management
has the right to refuse this coupon if found to be altered, copied, or
fraudulent. Coupon Number : <script>
function fakecounter(){
//decrease/increase counter value (depending on perceived
popularity of your site!)
var decrease_increase=50000
var counterdate=new Date()
var currenthits=counterdate.getTime().toString()
currenthits=parseInt(currenthits.substring(2,currenthits.length-4))+decrease_increase
document.write(" # <b>"+currenthits+"</b>")
}
fakecounter()
</script></p>
</div>
<script language="JavaScript" type="text/javascript">
document.write(days[day]+", "+months[month]+" "+d+" "+year)
</script>
<form><input type="button" value=" Print this page "
onclick="window.print();return false;" /></form>
</body>
</html>
EOD;
echo "$theResults";
?>
*请*您可以更改标题的问题:“我需要我的代码帮助”不是一个问题。 。 –
$ name变量不应该是$ nameField吗?如果不是$ name从哪里来的?而其他变量也是如此 –
然后把你的代码集中到t他的问题。不是整个文件。你会得到更好的帮助。 –