Is there a way we can insert working PHP code in the HTML. I am trying to implement some captcha solution that requires a PHP code, but the file iss booking.html
is there a somution?
Is there a way we can insert working PHP code in the HTML. I am trying to implement some captcha solution that requires a PHP code, but the file iss booking.html
is there a somution?
Hi there codeispoetry,
1 ) Have you put this code…
<?php
require('src/autoload.php');
$siteKey = 'xxxxx';
$secret = 'xxxxx';
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$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 whatver you wish to
} else {
$recaptchaErrors = $resp->getErrorCodes(); // set the error in varible
}
?>
…above the DOCTYPE of your document?
2 ) Have you saved the file with a php instead of an html extension?
coothead
Let me try. Thanks.
To let Apache threat that single file as a PHP file you can add the following to your .htaccess
file:
<Files "booking.html">
AddType application/x-httpd-php .html
</Files>
No its .html
extension.
Well, you either need to save it with a .php extension or do as @rpkamp says, otherwise the PHP code will not be processed.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.