I am trying to create an error message within a a Captcha Form when the user enters the wrong code:
<?php if(isset($_GET['wrong_code'])){ ?>
<div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:180px;">Wrong verification code</div><br />
<?php ;}?>
Another php file sends the result of the captcha code check back in the 'wrong_code' parameter.
When I save and run the file as a .php file it operates perfectly, however I am stuck using html/htm files (due to many years of Google knowing these files) and the html/htm files show the above div upon loading.
I have tried modifying .htaccess by adding various iterations of the statements below to get the html files to act more PHP. this did not work:
AddType application/x-httpd-php .php .html
AddHandler php-script .php .html
I am operating on a form with very little space so I just want an error message that opens up a line under the captcha box in red to tell the user the code is wrong. Where am I going wrong? Should I be doing this another way?
All help gratefully appreciated.
Have you tried this in your .htaccess?
RewriteEngine On
RewriteRule ^(.+)\.html$ $1.php
Edit: doing this would mean you'd need to convert your .html files to .php files Which you can do with a PHP file:
<?php
$files = scandir(getcwd());
foreach($files as $file) {
if(pathinfo($file, PATHINFO_EXTENSION) == 'html'){
rename($file, pathinfo($file, PATHINFO_FILENAME) .'php');
}
}
?>