Jump to content

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("insertemail@email.com","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("insertemail2@email.com","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 = 'insertemail@email.com, email2@email.com, email3@email.com';
$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 = 'insertemail@email.com, email2@email.com, ' . $_POST['field_6'];

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.