[code]
?php
// == Complete PHP Form ==
// note you will need an emails.txt file so this form know where to send it's info Download this from the "DocMon" files FTP
$num = 5;
$result = $num * 'hello';
//$today = date('Y');
//echo $result;
// if the form has been submitted
if ( $_GET['action'] == 'send' ) {
// if email isn't blank and message isn't blank
if ( $_POST['email'] != '' && $_POST['message'] != '' ) {
// make sure email address is in the proper format
if ( preg_match('/(.*)\@(.*)\.(.*)/', $_POST['email']) ) {
// create an array from the emails.txt file - these are the emails this for is being sent to.
$emails = file('emails.txt');
// this would be a string
$email_list = file_get_contents('emails.txt');
// semd the message to each address
foreach ( $emails as $email ) {
// send to this address
$to = trim($email);
// with this subject
$subject = 'Squirrel-Tech.com Form Completed by' . " " . "$name";
// and this message (removing spam from the message)
//$message = remove_spam($_POST['message']); This was the orgianl gefor I made the message change JK
$message = 'Squirrel-Tech.com Form Completed by' ." ". "$name" ." ". "$phone" ." ". "$message" ." ". 'form was completed on' ." ". date('l jS \of F Y h:i:s A');
// from this address (escaping all inputs for potential spam injections)
$headers = 'From: '. remove_spam($_POST['name']) . ' <' . remove_spam($_POST['email']) . '>';
// send mail
mail($to, $subject, $message, $headers);
// tell the user it worked
//echo '
Thanks for the message!
';
//echo '
Message sent to: '. $to . '
'; ** this line will show all the emails the form was sent too JK
$count=1; // this is the counter for the email JK
$count++;// this increments up for each email address in the list JK
}
echo 'Thank You' ." ". "$name" . "‚ " . 'Your message was sent to our Tech’s at Squirrel-Tech.com'; //this leaves a message that # of emails were sent counter $count removed JK
}
else {
echo '
Invalid email address!
';
}
}
// otherwise, print an error message
else {
echo '
Missing required fields!
';
}
}
function remove_spam($str) {
// email headers that we don't want users to submit
$bad_headers = array(
'to:',
'from:',
'bcc:',
'cc:',
'content-transfer-encoding',
'content-type',
'mime-version'
);
// loop thru each element of the bad_headers array
foreach ( $bad_headers as $h ) {
// replace the value of $h with this text (if it exists in $str)
$str = str_replace($h, '(maybe a spam header)', $str);
}
// don't allow any html
$str = str_replace('<', ' ', $str);
$str = str_replace('>', ' ', $str);
$str = htmlentities($str);
return $str;
}
?>[/code]
[code]
| For information
about our
services, please complete the
form below. We will get back to you promptly. Your satisfaction is our priority! |
