Jump to content

Form email copy to user


tracyaf_2

Recommended Posts

Hey, I'm new here I don't know much at all about php, and I used a form generator to create my code. My issue is that I want it to email the person filling out the form, and two other people. I have gotten the 2 people two work, however I can't get the other email to send.  This is my code:

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

mail("[email protected]","Title Evidence - Form submission","Title Evidence:

Business Name: " . $_POST['field_1'] . " 
Office Address: " . $_POST['field_2'] . " 
Your Name: " . $_POST['field_3'] . " 
Your Phone: " . $_POST['field_4'] . " 
Your Fax (optional): " . $_POST['field_5'] . " 
Your Email: " . $_POST['field_6'] . " 
Property Address: " . $_POST['field_7'] . " 
Transaction Type: " . $_POST['field_8'] . " 
Seller(s): " . $_POST['field_9'] . " 
Sellers Agent: " . $_POST['field_18'] . " 
Buyer(s): " . $_POST['field_10'] . " 
Buyers Agent: " . $_POST['field_17'] .  " 
Sales Price: " . $_POST['field_11'] . " 
Lender (optional): " . $_POST['field_12'] . " 
Loan Amount (optional): " . $_POST['field_13'] . " 
Estimated Closing Date: " . $_POST['field_14'] . " 
Closing Location: " . $_POST['field_15'] . " 
Comments (optional): " . $_POST['field_16'] );

include("confirm.html");

?>

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

mail("[email protected]","Title Evidence - Form submission","Title Evidence:

Business Name: " . $_POST['field_1'] . " 
Office Address: " . $_POST['field_2'] . " 
Your Name: " . $_POST['field_3'] . " 
Your Phone: " . $_POST['field_4'] . " 
Your Fax (optional): " . $_POST['field_5'] . " 
Your Email: " . $_POST['field_6'] . " 
Property Address: " . $_POST['field_7'] . " 
Transaction Type: " . $_POST['field_8'] . " 
Seller(s): " . $_POST['field_9'] . " 
Sellers Agent: " . $_POST['field_18'] . " 
Buyer(s): " . $_POST['field_10'] . " 
Buyers Agent: " . $_POST['field_17'] .  " 
Sales Price: " . $_POST['field_11'] . " 
Lender (optional): " . $_POST['field_12'] . " 
Loan Amount (optional): " . $_POST['field_13'] . " 
Estimated Closing Date: " . $_POST['field_14'] . " 
Closing Location: " . $_POST['field_15'] . " 
Comments (optional): " . $_POST['field_16'] );;

?>

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

mail(". $_POST[field_6] .","Title Evidence - Form submission","Title Evidence:

Business Name: " . $_POST['field_1'] . " 
Office Address: " . $_POST['field_2'] . " 
Your Name: " . $_POST['field_3'] . " 
Your Phone: " . $_POST['field_4'] . " 
Your Fax (optional): " . $_POST['field_5'] . " 
Your Email: " . $_POST['field_6'] . " 
Property Address: " . $_POST['field_7'] . " 
Transaction Type: " . $_POST['field_8'] . " 
Seller(s): " . $_POST['field_9'] . " 
Sellers Agent: " . $_POST['field_18'] . " 
Buyer(s): " . $_POST['field_10'] . " 
Buyers Agent: " . $_POST['field_17'] .  " 
Sales Price: " . $_POST['field_11'] . " 
Lender (optional): " . $_POST['field_12'] . " 
Loan Amount (optional): " . $_POST['field_13'] . " 
Estimated Closing Date: " . $_POST['field_14'] . " 
Closing Location: " . $_POST['field_15'] . " 
Comments (optional): " . $_POST['field_16'] );;

?>

Link to comment
https://forums.phpfreaks.com/topic/203274-form-email-copy-to-user/
Share on other sites

form-process.php

function clean($value) {
  $value = strip_tags($value);
  $value = htmlentities($value);
  return $value;
}

$_POST = array_map('clean', $_POST);

//$url = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']);

$from = '';//your e-mail

$to = '[email protected], [email protected], [email protected]';
$subject = 'Title Evidence - Form Submission';
$message = '';
$headers = 'From: ' . $from . "\r\n";
$headers.= 'Reply-To: ' . $from . "\r\n";
$headers.= 'Return-Path: ' . $from . "\r\n";

$message = <<<MAIL
Business Name: $_POST['field_1']
Office Address: $_POST['field_2'] 
Your Name: $_POST['field_3']
Your Phone: $_POST['field_4']
Your Fax (optional): $_POST['field_5']
Your Email: $_POST['field_6']
Property Address: $_POST['field_7']
Transaction Type: $_POST['field_8'] 
Seller(s): $_POST['field_9'] 
Sellers Agent: $_POST['field_18'] 
Buyer(s): $_POST['field_10'] 
Buyers Agent: $_POST['field_17']
Sales Price: $_POST['field_11'] 
Lender (optional): $_POST['field_12'] 
Loan Amount (optional): $_POST['field_13'] 
Estimated Closing Date: $_POST['field_14'] 
Closing Location: $_POST['field_15'] 
Comments (optional): $_POST['field_16']
MAIL;

if (mail($to, $subject, $message, $headers)) {
  include('confirm.html');
} else {
  include('failed.html');
}

 

Use as:

 

<?php if (!empty($_POST)): include('form-process.php'); endif; ?>
<form action="#" ..

Sorry I wasn't clear enough, thanks for cleaning up my code, but what I need is to send a copy of the email to the input from field 6

 

Thx, how could I be so dumb forgetting field_6 is an email_address.

 

$to = '[email protected], [email protected], ' . $_POST['field_6'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.