Note that there are some explanatory texts on larger screens.

plurals
  1. POCopy HTML form in email PHP
    text
    copied!<p>I am trying to copy my HTML form in email body. Below is code where the form is already in php file but I want if the user submits html form file then all the form data between that is not hidden is copied (as disabled elements) in the body of the email. Also if there is any file attachment field, it should be attached to the email.</p> <pre><code>&lt;?php // multiple recipients $to = 'demo@localhost.com' . ', '; // note the comma $to .= 'demo@localhost.com'; // subject $subject = 'Birthday Reminders for August'; // message $message = ' &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;/head&gt; &lt;body style="padding:3px; margin:0px;" bgcolor="#FFFFFF"&gt; &lt;table cellpadding="0" cellspacing="0" border="0" width="440"&gt; &lt;tr&gt;&lt;td style="height:10px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" style="text-align:justify; line-height:15px;" class="body"&gt; &lt;form name="frm" method="POST" action="careersuccess.php" enctype="multipart/form-data"&gt; &lt;table cellpadding="0" cellspacing="0" border="0" width="100%"&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; Name&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;input type="text" name="strname" class="textfield"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:3px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; Address&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;textarea cols="16" name="straddress"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:3px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; City&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;input type="text" name="strcity" class="textfield"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:3px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; State&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;input type="text" name="strstate" class="textfield"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:3px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; Contact No&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;input type="text" name="strno" class="textfield"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:3px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; Email&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;input type="text" name="stremail" class="textfield"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:3px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; Comments&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;textarea cols="16" name="strcomments"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:3px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="23%" class="body"&gt; Resume&lt;/td&gt; &lt;td width="3%" class="body"&gt;:&lt;/td&gt; &lt;td width="74%"&gt;&lt;input type="file" name="strresume"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="height:10px"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" align="center"&gt; &lt;/td&gt; &lt;/tr&gt; &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"; // Additional headers $headers .= 'To: Mary &lt;mary@example.com&gt;, Kelly &lt;kelly@example.com&gt;' . "\r\n"; $headers .= 'From: Birthday Reminder &lt;birthday@example.com&gt;' . "\r\n"; $headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?&gt; </code></pre>
 

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