0

So here is my latest question team...

The project I am working now the I needs to be modified..

Its a form with checkboxes on who you would like to send this message to... at first I thought it was fine just sending out with everyone on the "to:" list of recipients but now maybe I want to have it send out each email as a separate email...

Here is my script...

// Connect to server and select database. 
mysql_connect("$hostname", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 

// Get values from form 
$first=$_POST['firstprospect']; 
$last=$_POST['lastprospect']; 
$address=$_POST['addressprospect']; 
$city=$_POST['cityprospect']; 
$state=$_POST['stateprospect']; 
$zip=$_POST['azipprospect']; 
$prefix=$_POST['prefixprospect']; 
$email=$_POST['email0']; 
$fmail1=$_POST['fmail1'];
$fmail2=$_POST['fmail2'];
$fmail3=$_POST['fmail3'];
$fmail4=$_POST['fmail4'];
$prefix=$_POST['prefixprospect'];
$message=$_POST['prospectmessage'];


// Insert data into mysql 
$sql="INSERT INTO $tbl_name(firstprospect, lastprospect, addressprospect, cityprospect, stateprospect, azipprospect, prefixprospect, email0, fmail1, fmail2, fmail3, fmail4, prospectmessage)
VALUES('$firstprospect', '$lastprospect', '$addressprospect', '$cityprospect', '$stateprospect', '$azipprospect', '$prefixprospect', '$email0', '$fmail1', '$fmail2', '$fmail3', '$fmail4', '$prospectmessage')"; 
$result=mysql_query($sql); 
mysql_select_db($dbname);

if(count($_POST)) {
foreach(array('fmail1','fmail2','fmail4','fmail3','email0','firstprospect','lastprospect','addressprospect','cityprospect','stateprospect','azipprospect','prefixprospect') as $key) $_POST[$key] = strip_tags($_POST[$key]);
if(!is_secure($_POST)) { die("thank you no thanks");}

# submits a notification to you when 
# the form is submitted

// Email address for copies to be sent to - sean@surfgraphics
$emailto = "myemail@email.com"; 
}
// Notification email subject text for copies
$esubject = "<<<BNE TAKE ACTION test SUBMISSION>>>"; 

// Email body text for notifications
$emailtext = "
$_POST[prefixprospect] $_POST[firstprospect] $_POST[lastprospect]
$_POST[addressprospect]
$_POST[cityprospect],$_POST[stateprospect] $_POST[azipprospect] 

$_POST[prospectmessage]

Has sent a Take Action email to following recipients:

$_POST[fmail1]
$_POST[fmail2]
$_POST[fmail3]
$_POST[fmail4]

";

# This function sends the email to you

@mail("$emailto", $esubject, $emailtext, "From: $_POST[email0]");

# This part is the function for sending to recipients

// Page to display after successful submission
// Change the thankyou.htm to suit

$thankyoupage = "index.html"; 

// Subject line for the recommendation - change to suit

$tsubject = "My support of Wind Prospect ";

// Change the text below for the email 
// Be careful not to change anyt "$_POST[value]" bits

$ttext = "

To: Our Local Prospect Official,
Subject: My support of Wind Prospect 

$_POST[prospectmessage]

Thank you...
$_POST[prefixprospect] $_POST[firstprospect] $_POST[lastprospect]
$_POST[addressprospect]
$_POST[cityprospect],$_POST[stateprospect] $_POST[azipprospect]
$_POST[email0]
";

# This sends the note to the addresses submitted
@mail("$_POST[fmail1],$_POST[fmail2],$_POST[fmail3],$_POST[fmail4]", $tsubject, $ttext, "FROM: $_POST[email0]");

# After submission, the thank you page
header("Location: $thankyoupage");
exit;


# Nothing further can be changed. Leave the below as is

function is_secure($ar) {
$reg = "/(Content-Type|Bcc|MIME-Version|Content-Transfer-Encoding)/i";
if(!is_array($ar)) { return preg_match($reg,$ar);}
$incoming = array_values_recursive($ar);
foreach($incoming as $k=>$v) if(preg_match($reg,$v)) return false;
return true;
}

function array_values_recursive($array) {
$arrayValues = array();
foreach ($array as $key=>$value) {
if (is_scalar($value) || is_resource($value)) {
$arrayValues[] = $value;
$arrayValues[] = $key;
}
elseif (is_array($value)) {
$arrayValues[] = $key;
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}
?>
2
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by Electricfan
0

SO I need to modify line 91 so it sends it as individual emails instead of multiple names on to list..

Thanks as always....

0

If you are doing this for privacy reasons, you could also make all of the addressees BBC's and use yourself as the To.

0

no just so they think they are the only one getting this.. so I would want each person to be in the to: line by themselves..

Edited by Electricfan: n/a

0

You need a loop around the mail statement or if it is always limited to 4 addresses you could just repeat the mail statement 4 times with one addressee in each one.

0

that worked... But I'm getting internal server error now... Not sure if its a coincidence or not...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.