SHARE
TWEET

Untitled

a guest Jan 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function spamcheck($field) {
  2.     // filter_var() sanitizes the e-mail
  3.     // address using FILTER_SANITIZE_EMAIL
  4.     $field = filter_var($field, FILTER_SANITIZE_EMAIL);
  5.  
  6.     // filter_var() validates the e-mail
  7.     // address using FILTER_VALIDATE_EMAIL
  8.     if(filter_var($field, FILTER_VALIDATE_EMAIL)) {
  9.         return TRUE;
  10.     }
  11.     else {
  12.         return FALSE;
  13.     }
  14. }
  15.  
  16. if(isset($_REQUEST['email'])) {
  17.     // if "email" is filled out, proceed
  18.     // check if the email address is invalid
  19.     $mailcheck = spamcheck($_REQUEST['email']);
  20.     if ($mailcheck==FALSE) {
  21.         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>");
  22.     }
  23.     else {//send email
  24.         $to = "$email";
  25.         $from = "name@mywebsite.com";
  26.         $message = "Just a message";
  27.         $subject = "Subject";
  28.  
  29.         mail($to, $message, $subject, "From: $from", "-f$from");
  30.     }
  31. }
  32.    
  33. function checkEmail($input)
  34. {
  35.   return filter_var($input, FILTER_VALIDATE_EMAIL);
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top