Hello,
I have a php script that gets data from a form, screens for Spam and sends an email. It used to work fine in PHP 5.2 but it is no longer passing variables in PHP version 5.6.
Is it possible to get a friendly help to check in which part the code needs change ?
Thanks in advance !
[code=php]
<?
$contactName=$_POST[‘contactName’];
$email=$_POST[’email’];
$phone=$_POST[‘phone’];
$commentsText=$_POST[‘commentsText’];
// Select if you want to check form for standard spam text
$SpamCheck = “Y”; // Y or N
$SpamReplaceText = “*content removed*”;
// Error commentsText prited if spam form attack found
$SpamErrorcommentsText = “<p align=”center”><font color=”red”>Malicious code content detected.
</font><br><b>Your IP Number of <b>”.getenv(“REMOTE_ADDR”).”</b> has been logged.</b></p>”;
$contactcontactName = $HTTP_POST_VARS[‘contactName’];
$email = $HTTP_POST_VARS[’email’];
$phone = $HTTP_POST_VARS[‘phone’];
$commentsText = $HTTP_POST_VARS[‘commentsText’];
$headers = “From: $emailn”;
$headers . “MIME-Version: 1.0n”
. “Content-Transfer-Encoding: 7bitn”
. “Content-type: text/html; charset = “iso-8859-1″;nn”;
if ($SpamCheck == “Y”) {
// Check for Website URL’s in the form input boxes as if we block website URLs from the form,
// then this will stop the spammers wastignt ime sending emails
if (preg_match(“/http/i”, “$contactName”)) {echo “$SpamErrorcommentsText”; exit();}
if (preg_match(“/http/i”, “$email”)) {echo “$SpamErrorcommentsText”; exit();}
if (preg_match(“/http/i”, “$phone”)) {echo “$SpamErrorcommentsText”; exit();}
if (preg_match(“/http/i”, “$info”)) {echo “$SpamErrorcommentsText”; exit();}
// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer
$pattern = ‘/(;|||`|>|<|&|^|@|”|’.”n|r|'”.’|{|}|[|]|)|()/i’; // build the pattern match string
$contactcontactName = preg_replace($pattern, “”, $contactcontactName);
$phone = preg_replace($pattern, “”, $phone);
$commentsText = preg_replace($pattern, “”, $commentsText);
// Check for the injected headers from the spammer attempt
// This will replace the injection attempt text with the string you have set in the above config section
$find = array(“/bcc:/i”,”/Content-Type:/i”,”/cc:/i”,”/to:/i”);
$email = preg_replace($find, “$SpamReplaceText”, $email);
$contactName = preg_replace($find, “$SpamReplaceText”, $contactName);
$phone = preg_replace($find, “$SpamReplaceText”, $phone);
$commentsText = preg_replace($find, “$SpamReplaceText”, $commentsText);
// Check to see if the fields contain any content we want to ban
if(stristr($contactName, $SpamReplaceText) !== FALSE) {echo “$SpamErrorcommentsText”; exit();}
if(stristr($phone, $SpamReplaceText) !== FALSE) {echo “$SpamErrorcommentsText”; exit();}
if(stristr($commentsText , $SpamReplaceText) !== FALSE) {echo “$SpamErrorcommentsText”; exit();}
// Do a check on the send email and subject text
if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo “$SpamErrorcommentsText”; exit();}
if(stristr($subject, $SpamReplaceText) !== FALSE) {echo “$SpamErrorcommentsText”; exit();}
}
$commentsText1=”
******Contato********
Nome: $contactName
email: $email
phone: $phone
commentsText: $commentsText
“;
$body = $commentsText1;
$to = ‘[email protected]’ . ‘, ‘;
$to .= ‘[email protected]’;
$sent=mail($to,’Contact’, $body, $headers);
if($sent)
{
require (“thankyou.html”); }
else
{echo”An error ocurred !”; }
?>