Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my PHP script sending blank emails?
    primarykey
    data
    text
    <p>When I render it on the server side after uploading, I get an email but it is blank. The From is blank the text is blank the part in ECHO where $name is comes out blank. Any ideas what I can do to make this work?</p> <p>Here is my form:</p> <pre><code>&lt;form action="survey.php" method="post" name="survey"&gt; &lt;table&gt;`enter code here` &lt;tr&gt;&lt;th colspan="2"&gt;Survey&lt;/th&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Name:&lt;/td&gt;&lt;td align="center"&gt;&lt;input type="text" name="name" id="name" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;When was your last visit&lt;/td&gt;&lt;td align="center"&gt;&lt;select id="long" name="long"&gt; &lt;option value="Select"&gt;Please Select&lt;/option&gt; &lt;option value="1-2 days"&gt;1-2 days ago&lt;/option&gt; &lt;option value="3-5 days"&gt;3-5 days ago&lt;/option&gt; &lt;option value="1-2 weeks"&gt;1-2 weeks ago&lt;/option&gt; &lt;option value="3-5 weeks"&gt;3-5 weeks ago&lt;/option&gt; &lt;option value="2 months"&gt;2 months&lt;/option&gt; &lt;option value="3+months"&gt;3+ months &lt;/option&gt; &lt;option value="Never"&gt;Never Visited&lt;/option&gt; &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Tell us about your experience?&lt;/td&gt;&lt;td align="center"&gt;&lt;textarea cols="22" rows="5" id="experience" name="experience"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Will you come back to visit again?&lt;/td&gt;&lt;td align="center"&gt;&lt;input type="checkbox" id="visit" name="visit" value="Yes" /&gt;Yes&lt;input type="checkbox" id="visit" name="visit" value="No" /&gt;No&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td colspan="2"&gt;&lt;input type="submit" value="Submit" /&gt;&lt;input type="reset" value="Reset" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>And my PHP code</p> <pre><code>&lt;?php /* subject and e-mail variables*/ $emailSubject = $name; $webMaster = 'patrick@patrickspcrepair.com'; /* Gathering data Variables */ $nameField = $_POST['name']; $selectField = $_POST['long']; $commentsField = $_POST['experience']; $visitField = $_POST['visit']; $body = &lt;&lt;&lt;EOD &lt;br&gt;&lt;hr&gt;&lt;br&gt; Name: $name&lt;br&gt; Date of last visit: $long&lt;br&gt; Expierence: $experience&lt;br&gt; Visit again: $visit&lt;br&gt; 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 &lt;&lt;&lt;EOD and the EOD; If they are deleted this form will not work */ $theResults = &lt;&lt;&lt;EOD &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Coupon&lt;/title&gt; &lt;script language="javascript" type="text/javascript"&gt; var d=datetime.getDate() var datetime=new Date() var day=datetime.getDay() var month=datetime.getMonth() var year=datetime.getYear() if (year &lt; 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") &lt;/script&gt; &lt;style type="text/css"&gt; #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; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="frame"&gt; &lt;h3 align="center"&gt;Thanks for Participating in our survey, $name!&lt;/h3&gt; &lt;p align="center"&gt;Here is a special offer for you:&lt;/p&gt; &lt;h2 align="center"&gt;Free Egg Roll!&lt;/h2&gt; &lt;p align="center"&gt;Please print out this coupon to recieve a free egg roll with the purchase of a meal.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="font-size:x-small"&gt;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 : &lt;script&gt; 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(" # &lt;b&gt;"+currenthits+"&lt;/b&gt;") } fakecounter() &lt;/script&gt;&lt;/p&gt; &lt;/div&gt; &lt;script language="JavaScript" type="text/javascript"&gt; document.write(days[day]+", "+months[month]+" "+d+" "+year) &lt;/script&gt; &lt;form&gt;&lt;input type="button" value=" Print this page " onclick="window.print();return false;" /&gt;&lt;/form&gt; &lt;/body&gt; &lt;/html&gt; EOD; echo "$theResults"; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload