0

I have recaptcha and a form on my contact page. Everything has been working (for months) until I had to change out the navigation menu. As soon as I did that, all the PHP etc. code above the "" started displaying at the top of the page. It covers my logo and navbar. What can I do? Can anyone help?

Here is a screen shot: Code showing on top of page

<?php
require( 'recaptcha-master/src/autoload.php' );
$siteKey = '6LcM_wkUAAAAALpmz...';
$secret = '6LcM_wkUAAAAAJO-U04kp...';
$recaptcha = new\ ReCaptcha\ ReCaptcha( $secret, new\ ReCaptcha\       RequestMethod\ SocketPost() );

if ( !empty( $_POST )and isset( $_POST[ 'g-recaptcha-response' ] ) ):

$gRecaptchaResponse = $_POST[ 'g-recaptcha-response' ]; //google captcha     post data
$remoteIp = $_SERVER[ 'REMOTE_ADDR' ]; //to get user's ip
$recaptchaErrors = ''; // blank varible to store error
$resp = $recaptcha->verify( $gRecaptchaResponse, $remoteIp ); //method to        verify captcha
if ( $resp->isSuccess() ) {
// send mail or insert in db or do whatever you wish to
$headers = 'From: CBS.Website - info@cb.com.';
$emailbody = 'Name: ' . $_POST[ 'name' ] . "\n"
. 'Company: ' . $_POST[ 'company' ] . "\n"
. 'Email: ' . $_POST[ 'email' ] . "\n"
. 'Phone: ' . $_POST[ 'phone' ] . "\n"
. 'Referral: ' . $_POST[ 'referral' ] . "\n"
. 'Stage: ' . $_POST[ 'stage' ] . "\n"
. 'Budget Range: ' . $_POST[ 'budget' ] . "\n"
. 'Geographic Location: ' . $_POST[ 'location' ] . "\n"
. 'Type: ' . $_POST[ 'type' ] . "\n"
. 'Special Considerations: ' . $_POST[ 'considerations' ] . "\n"
. 'Project Type: ' . $_POST[ 'projectType' ] . "\n"
. 'Square Footage: ' . $_POST[ 'sqfootage' ] . "\n"
. 'Number of Stories: ' . $_POST[ 'stories' ] . "\n"
. 'Schedule: ' . $_POST[ 'schedule' ] . "\n"
. 'SF Budget: ' . $_POST[ 'sfbudget' ] . "\n"
. 'Future Construction: ' . $_POST[ 'futureConst' ] . "\n"
. 'Special Features: ' . $_POST[ 'features' ] . "\n"
. 'Restrictions: ' . $_POST[ 'restrictions' ] . "\n";


    mail( 'sg@cb.com', 'Contact Form Submission', $emailbody, $headers );

    echo "<meta http-equiv='refresh' content=\"0; url=thankyou.php\">";

} else {
    $recaptchaErrors = $resp->getErrorCodes(); // set the error in varible
}
endif;
?>
<!doctype html>
<html>
<head>
Newsong80
  • 99
  • 1
  • 10
  • If PHP code is displaying on the page sounds more like a server issue than a PHP problem. – Brack Jun 04 '19 at 00:21
  • But it is local. I'm not dealing with a server currently. It happens when I change out my nav menu. If I leave the old menu on, it is fine. I know that doesn't make sense. – Newsong80 Jun 04 '19 at 22:52
  • PHP requires a webserver to be processed. If you're just opening a PHP file in your browser it will not process the code and will display it in the browser. Look into XAMPP if you're on Windows, LAMP if you're on Linux, or MAMP on OSX. – Brack Jun 06 '19 at 22:44

0 Answers0