/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Php Form not working in PHP 5.6

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 !”; }

?>
[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmSep 25.2015 — http_post_vars???? That's been deprecated for many versions. Why are you using it?

Turn on php error checking - see my signature.
Copy linkTweet thisAlerts:
@NogDogSep 25.2015 — Yeah, that's probably your problem, and easily fixed by a global search/replace in your PHP files, changing $HTTP_POST_VARS to $_POST. There are some subtle differences between the two, but 99%+ of the time it should not matter. ($HTTP_POST_VARS is not "super-global" while $_POST is.)
Copy linkTweet thisAlerts:
@sandro27authorSep 29.2015 — Hey Guys,

I changed the $HTTP_POST_VARS for $_POST and worked. Yeah, it is old code and unfortunately I am don't review my php code much. I just know when something is deprecated when it stop working !

Any thanks a lot for your help !! Hey NogDog thank you for your help all these years !!
Copy linkTweet thisAlerts:
@NogDogSep 29.2015 — glad it was a relatively simple fix. Be sure to mark this thread resolved (assuming it is).
×

Success!

Help @sandro27 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...