13){
try {
//initialize the new code string
$newPW = "";
//go through to generate a random code.
$newPW .= substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'),1,8);
$Email = $_POST['email'];
$ConfirmationCode = $newPW;
$confirmation=0;
$fname=$_POST["FirstName"];
$sname = $_POST["SurName"];
$name = $fname." ".$sname;
$itemid =" ";
$phone = $_POST['phone'];
$terms =$_POST['terms'];
$today=time();
$dateof=date('y-m-d',strtotime('+0 day',$today));
if(isset($name) && isset($_POST['email'] )){
$username = $name;
$Email = $_POST['email'];
}
// connect to the database
$servername = "localhost";
$user = "ecovibdc_tudsy66";
$password = "power99661";
$conn = new PDO("mysql:host=$servername;dbname=ecovibdc_Subscribers", $user, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//add the person to the database
$query = "INSERT INTO emailcomm (emailcommitemid,Ageofcommmember,nameofcommmember,emailaddress,phonenumberofcomm,termsofcom,ConfirmationCode,Confirmation)
VALUES ('$itemid','$age','$name','$Email','$phone','$terms','$ConfirmationCode','$confirmation')";
$conn->query($query) OR die(mysql_error());
$mail->Host='smtp.ecovib2d.com.au';
$mail->SMTPAuth =true;
$mail->Username ='ecovib2d@live.com';
$mail->Password ='power9966@CRAZY';
$mail->SMTPSecure = 'tls';
$mail->Port=25;
$mail->setFrom('ecovib2d@live.com','Adrian');
$mail->addReplyTo('ecovib2d@live.com','Adrian');
$mail->addAddress($Email,$name);
$mail->Subject = 'Welcome to the ECOVIB2D Community,'.$fname;
$mail->isHTML(true);
$message = "";
$message .= "Welcome to the Ecovib2d Community\r\n";
$message .= "Ecovib2d Confirmation: Welcome ".$fname."\r\n";
$message .= "You are receiving this email because you filled out a form on this website.\r\n";
$message .="If you did not fill out a form, you can simply delete this email. No further action is required.\r\n";
$message .="To complete confirmation and add your subscription, please click on the following link:\r\n";
$message .="https://ecovib2d.com.au/workfromhome/Emailcomm/confirm.php?c=$ConfirmationCode&t=$Email\r\n";
$message .="As mentioned, for joining the community you will receive a free eBook (Click the following link: https://ecovib2d.com.au/workfromhome/Emailcomm/handymanbiz1.pdf).\r\n";
$message .="Main site: https://ecovib2d.com.au/index.php\r\n";
$message .="Blog: https://ecovib2d.blogspot.com.au\r\n";
$message .="To Unsubscribe - Click this link: https://ecovib2d.com.au/workfromhome/unsubscribe/Usubscribe.php\r\n";
$message .="Thank you and hope you enjoy using Ecovib2d!\r\n";
$mail->Body = $message;
// Set debug output mode
$mail->Debug= TRUE;
$mail->Debugoutput= 'html';
if($mail->send()){
echo 'Your mail has been sent successfully.';
echo 'https://ecovib2d.com.au/workfromhome/Emailcomm/sub.html';
} else{
echo 'Unable to send email. Please try again. ';
echo 'Mailer Error: ' . $mail->ErrorInfo;
echo "Back to my site";
}
}
catch(PDOException $e)
{
echo "Error Message: " . $e->getMessage();
echo "Try again - ";
echo 'https://ecovib2d.com.au/index.php';
}
$conn=null;
}
else{
echo 'You are under 13-You need parental consent to subscribe';
echo 'Back to my site and try again';
echo 'https://ecovib2d.com.au/index.php';
}
?>