My online submission pages no longer work after upgrading to PHP v8. After pressing Submit, screen then turns white and no email sent with the submitted info. Screen is not supposed to turn white. After switching back to PHP 7.4, everything worked normally again. I have many online submission pages which all use the same code. The code never had any issues with any version of PHP dating back to 2011. Attached is one of the PHP programs. How can it be edited so it will work with PHP v8 ?

My online submission pages no longer work after upgrading to PHP v8. After pressing Submit, screen then turns white and no email sent with the submitted info. Screen is not supposed to turn white. After switching back to PHP 7.4, everything worked normally again. I have many online submission pages which all use the same code. The code never had any issues with any version of PHP dating back to 2011. Attached is one of the PHP programs. How can it be edited so it will work with PHP v8 ?
<?php
// grab recaptcha library
require_once "recaptchalib.php"; 
// foreach ($_POST as $key => $value) {
    //echo '<p><strong>' . $key.':</strong> '.$value.'</p>';
  // }
// your secret key
$secret = "6LeW4RQUAAAAAJ4NvgWIKJc4b-AeKp6LcLFCFQoS"; 

// empty response
$response = null; 

// check secret key
$reCaptcha = new ReCaptcha($secret); 
// if submitted check response
if ($_POST["g-recaptcha-response"]) { 
   $response = $reCaptcha->verifyResponse( 
          $_SERVER["REMOTE_ADDR"], 
       $_POST["g-recaptcha-response"] 
    ); 
} 
if ($response != null && $response->success) { 

$subject = "Showing Scheduling";
$message = "RadiantNewHorizonHomes.com Showing Scheduling" . "\r\n" . "\r\n" .
"Name: " . $_POST['ShowingName'] . "\r\n" .

"Phone Number : " . $_POST['ShowingPhone1'] . "\r\n" .

"E-mail Address: " . $_POST['ShowingEmail'] . "\r\n" .
"Properties wants to see: " . $_POST['ShowingHomes'] . "\r\n" .
"Date(s)/Time(s) wants to see them: " . $_POST['ShowingTimes'] . "\r\n" .






"Questions or Comments: " . $_POST['ShowingQuestions'] . "\r\n" .

"How Heard About Us: " . $_POST['ShowingHearing'] . "\r\n" .

$from = $_POST['ShowingEmail'];
$headers = "From: $from" . "\r\n";

$to = "david.tigner@radiantnewhorizonhomes.com";
mail($to,$subject,$message,$headers);


} else { } 

?>

Recommended Answers

All 5 Replies

Enable error logging and check the log files. Post back what you find.

The screen is turning white because of a fatal PHP error. Here is the list of backward incompatible changes between PHP versions 7 and 8.

A Google search is showing up that quite a handful of people have found that ReCaptcha is not compatible with PHP 8.0, but I did find someone say it's fine with PHP 8.1. Even that seems to be unsupported and iffy, though. What version of PHP 8 are you on?

When I go to the official documentation, it says that the version of ReCaptcha that you are using is no longer supported. Instead, you should upgrade to the Javascript-based Recaptcha v3.

This is good stuff. I don't have access to the php.ini file as that I believe is provided by the service provider, 1&1/Ionos. Versions of php v8 available from them are 8.0-8.4. Older versions available start with I think v4. They probably have the php.ini files. I do my programming using Dreamweaver and then I upload the files into 1&1/Ionos who then put everything on line. Also, I discovered in my notes on 12/9/21, I had upgraded to v7.4 and had written, "v8.1 is incompatible". What happened this time is 1&1/Ionos periodically puts out messages saying to update php version because of discontinued "support" and the new versions have support until the end of 2023-2025 depending on which v8 version selected. I had forgotten about the old incompatible note and upgraded to v8.4 as "support" for v7.4 ended 12/31/22. Then people started calling me saying the online submission forms weren't working. Testing confirmed that. I then switched back to v7.4 and they worked again. Interesting you mention about ReCaptcha as I had a feeling that might be the issue. I was going to remove all that from the coding and test again. I then decided using v7.4 was the better option as I wouldn't have to give up ReCaptcha ! I will be checking out Recaptcha v3 and incorporating it into my php pages. As far as which php v8.x to use, what do you suggest ? I have access to v8.0 - 8.4.

I cannot recommend which version of PHP 8 to upgrade to as I currently am using PHP 7.4 myself. For me, upgrading means going through the list of backward incompatible changes (linked to in my previous post above) and making any changes required to ensure none of my code will break when I upgrade. PHP 7.4 security patches stopped just over 3 months ago, so it really is in my very best interest to upgrade to PHP 8 as soon as possible.

However, I think PHP is only up to v 8.2.4, not version 8.4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.