Note that there are some explanatory texts on larger screens.

plurals
  1. POPhp form submitting to email
    primarykey
    data
    text
    <p>I am trying to take input from a form and email the results to me. I would like to format the email to look identical to what the customer sees when they are filling out the form (or very similar) I am having difficulties in trying to get this accomplished. Any help would be greatly appreciated.</p> <p>Here is my form data</p> <pre><code>&lt;form id="ContactKathryn" name="ContactKathryn" method="post" action="sendform/sendtokathryn.php"&gt; &lt;table width="60%" border="0" cellpadding="2px" style="position:relative; left:20%"&gt; &lt;tr&gt; &lt;td width="25%" align="right"&gt;Name:&lt;/td&gt; &lt;td width="75%" align="left"&gt;&lt;input name="ContactName" type="text" size="40" maxlength="100" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Email Address:&lt;/td&gt; &lt;td align="left"&gt;&lt;span id="sprytextfield1"&gt; &lt;input name="EmailAddress" type="text" id="EmailAddress" size="40" maxlength="150" /&gt; &lt;span class="textfieldRequiredMsg"&gt;A value is required.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Phone Number:&lt;/td&gt; &lt;td align="left"&gt;&lt;span id="sprytextfield2"&gt; &lt;label for="PhoneNumber"&gt;&lt;/label&gt; &lt;input name="PhoneNumber" type="text" id="PhoneNumber" maxlength="15" /&gt; &lt;span class="textfieldRequiredMsg"&gt;A value is required.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Practice Name:&lt;/td&gt; &lt;td align="left"&gt;&lt;input name="PracticeName" type="text" size="40" maxlength="100" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Message:&lt;/td&gt; &lt;td align="left"&gt;&lt;textarea name="Message" cols="40" rows="10"&gt;&amp;nbsp;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center" width="25%"&gt;&lt;/td&gt; &lt;td align="center" width="75%"&gt;&lt;input name="SubmitForm" type="submit" id="SubmitForm" onclick="MM_popupMsg('Are you sure you would like to submit this form?\r');return document.MM_returnValue" value="Submit Form" /&gt;&lt;input type="reset" name="ResetForm" id="ResetForm" value="Reset Form" /&gt;&lt;/td&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>and this is my PHP code:</p> <pre><code>&lt;?php // Where to redirect after form is processed. $url = 'http://www.mydomain.com'; // multiple recipients $to = '123456@gmail.com'; // note the comma // subject $subject = 'Someone sent you a contact request'; // message $message = '&lt;html&gt;&lt;body&gt; '; $message = 'MIME-Version: 1.0' . "\r\n"; $message = 'Content-type: text/html; charset=iso-8859-1'; $message = ' &lt;p&gt;Kathryn, someone sent you an email from the website&lt;/p&gt;'; $message = ' &lt;table&gt;'; $message = ' &lt;tr&gt;&lt;td&gt;Name:&lt;/td&gt;&lt;td&gt;'%$ContactName%'&lt;/td&gt;&lt;/tr&gt;'; $message = ' &lt;tr&gt;&lt;td align="right"&gt;Email Address:&lt;/td&gt;&lt;td align="left"&gt;'%$EmailAddress%'&lt;/td&gt;&lt;/tr&gt;'; $message = ' &lt;tr&gt;&lt;td align="right"&gt;Phone Number:&lt;/td&gt;&lt;td align="left"&gt;'%$PhoneNumber%'&lt;/td&gt;&lt;/tr&gt;'; $message = ' &lt;tr&gt;&lt;td align="right"&gt;Practice Name:&lt;/td&gt;&lt;td align="left"&gt;'%$PracticeName%'&lt;/td&gt;&lt;/tr&gt;'; $message = ' &lt;tr&gt;&lt;td align="right"&gt;Message:&lt;/td&gt;&lt;td align="left"&gt;'%$Message%'&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;'; $message = ' &lt;/table&gt;&lt;/body&gt;&lt;/html&gt;'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Mail it mail($to, $subject, $message, 'From: '.$EmailAddress.'', $headers); echo '&lt;META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'"&gt;' ?&gt; </code></pre> <p>The only thing I receive in the email when someone submits this form is: <code>&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</code></p>
    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