Jump to content

Sending processed form info as html to both the user and client


frshjb373

Recommended Posts

I am trying to build a form that will process all the user inputted information, and put those contents into an html table so that I can send the info to both my customer and myself.  I figured out how to send an email to myself as html, but the user email is arriving as plain text with all the html tags.  Someone had suggested PHPMailer, but I cannot figure out how to format it properly to work with my setup.  I am new to PHP so this is a learning curve.  I have included a sample of my process form with fictitious email addresses. Any help is much appreciated.  Thank you in advance for the help! 

 


<?php header("Location: ../contactthank.php"); 
?>

<?PHP
$field_Type = $_POST['field_Type'];
$field_Service_Provider = $_POST['field_Service_Provider'];
$field_Brand = $_POST['field_Brand'];
$field_Model = htmlspecialchars($_POST['field_Model']);
$field_Size = $_POST['field_Size'];
$field_Charger = $_POST['field_Charger'];
$field_Case = $_POST['field_Case'];
$field_Software = $_POST['field_Software'];
$field_Manual = $_POST['field_Manual'];
$field_Box = $_POST['field_Box'];
$field_Condition = $_POST['field_Condition'];
$field_FirstName = htmlspecialchars($_POST['field_FirstName']);
$field_LastName = htmlspecialchars($_POST['field_LastName']);
$field_Email = $_POST['field_Email'];
$field_ZipCode = (int)$_POST['field_ZipCode'];
$field_Comments = $_POST['field_Comments'];
?>

<?php $reference = (rand(100000000000,99999999999999)); 
	echo $reference;
?>

<?php
$to = "email@mail.com";
$subject = "Submission# $reference";
$headers = 'From: $field_Email'  . "\r\n";
$message =  '<html>
<head>
  <title>Cell Phone Form Submission</title>
</head>
<body>
  <h1>Thank you for your submission. We will get back to you shortly</h1>
<table border="1">
  <tr>
    <td>Reference#</td>
    <td>' . $reference . '</td>
  </tr>
  <tr>
    <td>I want to</td>
    <td><b>Sell</b></td>
  </tr>
  <tr>
    <td>Service Provider</td>
    <td>' . $field_Service_Provider . '</td>
  </tr>
  <tr>
    <td>Model</td>
    <td>' . $field_Model . '</td>
  </tr>
  <tr>
    <td>Size</td>
    <td> ' . $field_Size . '</td>
  </tr>
  <tr>
    <td>Accessories</td>
    <td>' . $field_Charger . " " . $field_Case . " " . $field_Software . " " . $field_Manual . " " . $field_Box . '</td>
  </tr>
  <tr>
    <td>Condition</td>
    <td>' . $field_Condition . '</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>' . $field_FirstName . " " . $field_LastName . '</td>
  </tr>
  <tr>
    <td>Email</td>
    <td>' . $field_Email . '</td>
  </tr>
  <tr>
    <td>Zip Code</td>
    <td>' . $field_ZipCode . '</td>
  </tr>
  <tr>
    <td>Comments</td>
    <td>' . $field_Comments . '</td>
  </tr>
</table></body>
</html>
';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$user = "$field_Email";
$usersubject = "Form Submission# $reference";
$userheaders = "From: email@mail.com\n";
$usermessage =  '<html>
<head>
  <title>Form Submission</title>
</head>
<body>
  <h1>Thank you. We will get back to you shortly</h1>
<table border="1">
  <tr>
    <td>Reference#</td>
    <td>' . $reference . '</td>
  </tr>
  <tr>
    <td>I want to</td>
    <td><b>Sell</b></td>
  </tr>
  <tr>
    <td>Service Provider</td>
    <td>' . $field_Service_Provider . '</td>
  </tr>
  <tr>
    <td>Model</td>
    <td>' . $field_Model . '</td>
  </tr>
  <tr>
    <td>Size</td>
    <td> ' . $field_Size . '</td>
  </tr>
  <tr>
    <td>Accessories</td>
    <td>' . $field_Charger . " " . $field_Case . " " . $field_Software . " " . $field_Manual . " " . $field_Box . '</td>
  </tr>
  <tr>
    <td>Condition</td>
    <td>' . $field_Condition . '</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>' . $field_FirstName . " " . $field_LastName . '</td>
  </tr>
  <tr>
    <td>Email</td>
    <td>' . $field_Email . '</td>
  </tr>
  <tr>
    <td>Zip Code</td>
    <td>' . $field_ZipCode . '</td>
  </tr>
  <tr>
    <td>Comments</td>
    <td>' . $field_Comments . '</td>
  </tr>
</table></body>
</html>
';

mail($to,$subject,$message,$headers);

mail($user,$usersubject,$usermessage,$userheaders,$headers);

?>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.