"; //.= to build upon a value of a variable (multiple error messages) } //VALIDATE FOR EMAIL $emailValidate = validate_email($userEmail); if(!$emailValidate){ $boolValidateOK = 0; $strValidationMessage .= "\n Please fill in a proper email address.
"; } //VALIDATE FOR MESSAGE if($userMessage == ""){ $boolValidateOK = 0; $strValidationMessage .= "\n Please fill in a message.
"; //.= to build upon a value of a variable (multiple error messages) } //VALIDATE AGAINST EMAIL INJECTIONS $badStrings = array("Content-Type", "MIME-Version:", "Content=Transfer-Encoding", "bcc:", "cc:"); foreach($_POST as $k => $v){ foreach($badStrings as $v2){ if(strpos($v,$v2) !== false){ $boolValidateOK = 0; $strValidationMessage .= "\n Sorry, there is something wrong with the formatting of your message. Please try again!
"; } } } if($boolValidateOK == 1){ //CREATE MAIL MESSAGE $mymail = "Email Sent From Atkey Tech Website \n\n"; $mymail .= "Name: $userName \n"; $mymail .= "Email: $userEmail \n"; $mymail .= "Message: $userMessage \n"; // CREATE HEADERS $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "X-Priority: 1\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php\n"; $headers .= "From:$userName <$userEmail> \r\n\r\n"; //Change these variables to match //RCIPIENT EMAIL ADDY $to = "kevin@atkeytech.com"; //Change this to where you need the email to go $subject = "Web Form Submission - Atkey Tech"; // ACTUALLY SEND THE MAIL MESSAGE mail($to, $subject, $mymail, $headers); //mail($name, $subject, $mymail, $headers); Would send a copy to the user //echo "Your email has been sent (we hope)"; header("Location: mail_confirm.htm"); } }// close if/then for submit //FUNCTION FOR EMAIL function validate_email( $senderemail ){ $email = trim( $senderemail ); # removes whitespace if(!empty($email) ): // validate email address syntax if( preg_match('/^[a-z0-9\_\.]+@[a-z0-9\-]+\.[a-z]+\.?[a-z]{1,4}$/i', $email, $match) ): return strtolower($match[0]); # valid! endif; endif; return false; # NOT valid! } //Close validate email function ?>
Atkey Logo

Contact Us

Have a question, or would like to consider AtkeyTech for your IT service? Send us a message, or give us a call at:

(780) 490-7511.

References are available upon request.


" />

" />