Hello,
The code below contains some PHP code that allows users to send out email invites to others. It works fine. However, I'm trying to add a function called "check_porn_terms" so that no user could enter their name as "porn" or other vulgar terms and then send an email under that name recommending my site. The variable "$_POST['sendername']" is the user's name.
The function below does not work. Any idea how I can get it to work?
Thanks in advance,
John
function check_porn_terms($input) {
$porn_terms = array("porn", "sex", "etc.");
return !preg_match('#\b(' . join('|', array_map('preg_quote', $porn_terms)) . ')\b#i', $input);
}
$sendername = $_POST['sendername'];
$sendername = strtolower($sendername);
if(!check_porn_terms($sendername))
{
session_write_close();
header("Location:http://www.site.com/friends.htm");
exit;
}
$msg = "<html><body>Hello, your friend ".htmlspecialchars($_POST['sendername'])." recommends that you use <a href='http://www.site.com/'>Site.com</a><br><br><img src='http://site.com/images/blacklogo.PNG'></body></html>";
$subject = "Try out Site.com";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $_POST['sendername'] . "\r\n";
foreach($_POST['email'] as $email){
mail($email, $subject,$msg,$headers);
}