Combining HTML and PHP - How to get Div statement not to show in .html files

I am trying to create an error message within a a Form when the user enters the wrong Captcha 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 error message 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 Captcha code is wrong. I want there to be no error message div shown upon loading and for the error message div to show only if the wrong_code parameter is sent back to the web page. Where am I going wrong? Should I be doing this another way?

All help gratefully appreciated.
Who is Participating?
Dave BaldwinFixer of ProblemsCommented:
You would probably be better off using javascript on the page to do this.  Give the 'div' an 'id' so javascript can find it and make the default be 'display:none;'
<div id="wrong" style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding- left:6px;width:180px;display:none;">Wrong verification code</div>

Open in new window

It took me a while but here's a demo.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

<title>JS query string</title>
<h1>JS query string</h1>

<input name="hello" id="hello" type="text" value="">
<br />
<div id="wrong" style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding- left:6px;width:180px;display:none;">Wrong verification code</div>
<br />

<a href="js-querystr3.html">js-querystr3.html</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="js-querystr3.html?wrong_code=true">js-querystr3.html?wrong_code=true</a>

<script type="text/javascript">
var nustr = location.href;
//document.write(nustr+" ");
var nuarr = new Array();
nuarr = nustr.split("=");
document.getElementById('hello').value = nuarr[1];
if(nuarr[1] == "true") {
	document.getElementById('wrong').style.visibility = 'visible';
	document.getElementById('wrong').style.display = 'block';
// -->


Open in new window

Who is your host - some have various techniques to parse html as php
AGoodwin42Author Commented:
Its Digital Pacific in Australia. I shall ask them.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

It's best as they will know how the server is setup and what directives to use.
(I'm assuming the question was just about getting html parsed as php?)
AGoodwin42Author Commented:
I was hoping to find another way. I only use php in a simple question form in a column on the website.

The host tells me that I can us the following rules:
RewriteEngine On
RewriteBase /
RewriteRule file1.html file1.php
The issue there is that every web page would now have to be processed server-side for a relatively small requirement.

I was hoping there was a simpler way to do display a simple error message without having to go full PHP.
That rewrite rule only rewrites that specific page (changing file1.html to your actual page name), not every page, so it is fine to use
You have to use PHP, there is no other way to do server side processing
AGoodwin42Author Commented:
Solved the problem
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.