Reply
An Array to CC Different Email Addresses in a Form
Old 02-16-2009, 10:14 AM An Array to CC Different Email Addresses in a Form
ADeacon's Avatar
Experienced Talker

Posts: 32
Name: Andrew
Location: Texas
Trades: 0
Hello,

I'm a novice with PHP. I have a problem getting a PHP script that in theory, should take a checkbox value in an HTML form (Mesa, Tucson, etc.) and apply it to an email, which resides in an array. It might be hung up on a function to include an attachment that the script contains as this particular form doesn't have that option. However, when I remove the attachment script, I get the same error. I'll include the PHP below as well as a link to the HTML form in question. Any pointers you can give me would be most appreciated. Thank you.

/---PHP---/

<?php

// Configuration Settings
require('mail/attach_mailer_class.php');
$sendername = 'Form Feedback';
$SendFrom = "ncapps@drawninwardmedia.com";
$SendTo = "ncapps@drawninwardmedia.com";
$CC = '';
$SubjectLine = "Request More Info: Full Application";
$file = null;
$ThanksURL = "thanks.html"; //confirmation page

// build list of office emails ($key = city $address = email address)
$locations = array();
$locations['Albany'] = 'dont@email.me';
$locations['Arlington'] = 'dont@email.me';
$locations['Clearwater'] = 'dont@email.me';
$locations['Colorado_Springs'] = 'dont@email.me';
$locations['Denver'] = 'dont@email.me';
$locations['Ft_Myers'] = 'dont@email.me';
$locations['Ft_Worth'] = 'dont@email.me';
$locations['Gainesville'] = 'dont@email.me';
$locations['Vegas'] = 'dont@email.me';
$locations['Mesa'] = 'dont@email.me';
$locations['Miami'] = 'dont@email.me';
$locations['Ocala'] = 'dont@email.me';
$locations['Phoenix'] = 'dont@email.me';
$locations['Port_Charlotte'] = 'dont@email.me';
$locations['Santa_Barbara'] = 'dont@email.me';
$locations['Santa_Maria'] = 'dont@email.me';
$locations['Sarasota'] = 'dont@email.me';
$locations['St_Petersburg'] = 'dont@email.me';
$locations['Syracuse'] = 'dont@email.me';
$locations['Tucson'] = 'dont@email.me';

// build email list string
foreach($_POST['interested_in'] as $location){
if($CC != '')
$CC .= ",$locations[$location]";
else
$CC .= $locations[$location];
}

// Build Message Body from Web Form Input
foreach ($_POST as $Field=>$Value){
$MsgBody .= "$Field: $Value\r\n";
}
if($_FILES['attachment']['tmp_name'] != ''){
move_uploaded_file($_FILES['attachment']['tmp_name'], './tmp/'.$_FILES['attachment']['name']);
$file = './tmp/'.$_FILES['attachment']['name'];
}
$MsgBody .= "\r\n" . @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\r\n" .
$_SERVER["HTTP_USER_AGENT"];
$MsgBody = htmlspecialchars($MsgBody, ENT_NOQUOTES); //make content safe

// Send E-Mail and Direct Browser to Confirmation Page
$mailer = new attach_mailer($sendername, $SendFrom, $SendTo, $CC, '', $SubjectLine, $MsgBody);
$mailer->extensions = array('.pdf', '.doc', '.docx', '.txt');
if($file != null){
$mailer->create_attachment_part($file);
}
if(!$mailer->process_mail()){
if($file != null)
unlink($file);
die('Could not send message. Please try again later.' . " $mailer->show_error_str()");
}
else
if($file != null){
unlink($file);
}
header("Location: $ThanksURL");
?>

/---END OF PHP---/

http://drawninwardmedia.com/nursecore/new_full_app.html

The checkboxes that pertain to the array are on part 3 of the form. Again, thanks for any help you may be able to provide.
ADeacon is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Reply     « Reply to An Array to CC Different Email Addresses in a Form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.08604 seconds with 13 queries