Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function spamcheck($field) {
- // filter_var() sanitizes the e-mail
- // address using FILTER_SANITIZE_EMAIL
- $field = filter_var($field, FILTER_SANITIZE_EMAIL);
- // filter_var() validates the e-mail
- // address using FILTER_VALIDATE_EMAIL
- if(filter_var($field, FILTER_VALIDATE_EMAIL)) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- if(isset($_REQUEST['email'])) {
- // if "email" is filled out, proceed
- // check if the email address is invalid
- $mailcheck = spamcheck($_REQUEST['email']);
- if ($mailcheck==FALSE) {
- die("<font color='red'>Your email address is invalid, please try again.</font><br/><br/><form><INPUT TYPE='button' VALUE='Back' onClick='history.go(-1);return true;'></form>");
- }
- else {//send email
- $to = "$email";
- $from = "name@mywebsite.com";
- $message = "Just a message";
- $subject = "Subject";
- mail($to, $message, $subject, "From: $from", "-f$from");
- }
- }
- function checkEmail($input)
- {
- return filter_var($input, FILTER_VALIDATE_EMAIL);
- }
Add Comment
Please, Sign In to add comment