return false;
} elseif (strlen($mystring) < $min) {
return false;
} else {
return true;
}
}
/* checks that a valid email address has been supplied */
function validate_email($e){
if (preg_match(‘#([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})#’, $e)){
return TRUE;
} else {
return FALSE;
}
}
if ($_POST[‘submit’] == “Submit”) {
// check fields have been entered correctly
$allokay = true;
if ($_SESSION[‘CAPTCHAString’] != $_POST[‘captchastring’]) {
// echo ”
Please try again – incorrect Security Test.
“;
$errortext = ”
- Incorrect Security Test.
“;
} else {
if (!checklength($_POST[’email_addr’],80, 5)) { $allokay = false; $errortext = ”
- Your Email Address is an invalid length.
“; }
if ($_POST[’email_addr’] != “”) {
if (!validate_email($_POST[’email_addr’])) { $allokay = false; $errortext .= ”
- Invalid Email Address.
“; }
}
if (!checklength($_POST[‘firstname’],40, 2)) { $allokay = false; $errortext .= ”
- Your First Name has been left blank or is an invalid length.
“; }
if (!checklength($_POST[‘surname’],40, 2)) { $allokay = false; $errortext .= ”
- Your Surname is an invalid length.
“; }
if ($_POST[‘how_heard’] == “”){ $allokay = false; $errortext .= ”
- You have not selected how you heard about Your Money Mistress. If you are not sure, please choose ‘Other’
“;}
if ($allokay) {
// code in here to process form / send emails etc.
// send email to Website Client
// this form is using the PHPMailer library, which more reliably handles HTML emails, but requires
// knowledge of the username and password for the email account being used to send
$myBody = ”
The following person just signed up for YMM blog:
“;
foreach ($_POST as $key => $value) {
if($key != “captchastring” && $key != “submit”){
$myBody .= $key . ” : $value
“;
}
}
require(“PHPMailer/class.phpmailer.php”);
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = “localhost”; // SMTP servers – often this is just localhost
$mail->SMTPAuth = false; // turn on SMTP authentication
$mail->SetLanguage(“en”, “PHPMailer/language/”);
$mail->From = “smile@yourmoneymistress.com”;
$mail->FromName = “Your Money Mistress Website”;
$mail->AddAddress(‘smile@yourmoneymistress.com’,’Smile at Your Money Mistress’);
$mail->AddBCC(“ssabet@contactpoint.com.au”,”Sanaz Sabet”); this line’s not required s it was a test to Sanaz when she made it. She’s now left the Design Company.
$mail->AddReplyTo(“smile@yourmoneymistress.com”,”Your Money Mistress”);
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = “Your Money Mistress Website blog submission”;
$mail->Body = $myBody;
/* $mail->AltBody = $textBody; */
if(!$mail->Send())
{
echo ”
Unfortunately there was an error processing your submission. Please try again.
“;
// exit;
} else {
echo ”
Thank you for subscribing to Your Money Mistress’ blog. Please check your Inbox as you will now be sent the first chapter of The Bedside Guide.
“;
echo ”
“;
echo ”
“;
echo ”
“;
echo ”
“;
echo ”
“;
//Send email with the attachment to the subscribers
$myBody = ”
Thank you for subscribing to Your Money Mistress’ blog. Your copy of the first chapter of The Bedside Guide: How to have Sizzling S*x & More Money in your relationship is attached.”;
$myBody .= ” Please add smile@yourmoneymistress.com to your safe list and Tell a friend to get the third chapter of the book.
“;
$myBody .= ”
Remember, at age 45 you only have 520 fortnightly pays until you turn 65 and every moment in time is an opportunity to choose your next move.
“;
$myBody .= ”
Wishing you more love and less debt.”;
$myBody .= ”
Whipping your wallet into shape!!
“;
$myBody .= “Learn to Dominate your Debt at www.yourmoneymistress.com
“;
$myBody .= “Visit my blog at www.yourmoneymistress.wordpress.com
“;
$myBody .= “Request me at your next event by Calling 1300 Whip it! (1300 9447 48)
“;
$myBody .= “Remember: Disobeying Your Money Mistress can be hazardous to your financial health!
“;
$myBody .= “YMM (aka Larissa Zimmerman) has a BSc (Maths), DipFS (Consumer Ed), Cert IV in Fitness (Personal Trainer), and Cert IV in Workplace Assessment & Training
“;
$myBody .= “ Please consider the environment before duplex printing this email. Thank you.
“;
$myBody .= “**************************************************************************
“;
$myBody .= “You are receiving this email due to your association with Larissa Zimmerman and Your Money Mistress. If you have received this email in error please notify the sender. If you wish to be removed from our mailing list respond to this email requesting to be unsubscribed from future communications.
“;
$myBody .= “**************************************************************************
“;
$mail->ClearAllRecipients();
$mail->ClearAddresses();
$mail->AddAddress($_POST[’email_addr’], $_POST[‘firstname’].” “.$_POST[‘surname’]);
$mail->AddAttachment(‘Ch1 for web.pdf’, ‘The Bedside Guide – Chapter 1.pdf’);
$mail->Subject = “The Bedside Guide – Chapter 1″;
$mail->Body = $myBody;
if(!$mail->Send())
{
echo ”
Unfortunately there was an error sending you the first chapter of The Bedside Guide. Please try again.
“;
// exit;
}
}
}
}
}
if ($_POST[‘submit’] != “Submit” || $errortext != “”) {
if ($errortext != “”) {
echo ”
Unfortunately an error has occurred when trying to record your submission:
“;
echo ”
- $errortext
“;
echo ”
Please try again.
“;
}
?>