Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Email Form Validation Related Functions (See related posts)

// Email form validation functions

<?php

// Function to look for suspicious looking text in submitted values
function is_injected($str) 
{
  $injections = array('(Content-Type:)','(MIME-Version:)','(Content-Transfer-Encoding:)','(From:)','(to:)','(cc:)','(bcc:)');
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str)) {
    return true;
  }
  else {
    return false;
  }
}

// Logic for page that calls the mail() function
if ($not_injected)
{
  // email send code...
}




/* Strips html tags and trims whitespace from data */
function clean_up($data) {
   $data = strip_tags($data);
   $data = trim(htmlentities($data));
   return $data;
}


?>


You need to create an account or log in to post comments to this site.


Related Posts