Forum Moderators: open

Message Too Old, No Replies

W3C validator Mystery

It validates but why?

         

bumpaw

3:19 am on May 13, 2004 (gmt 0)

10+ Year Member



I have a simple page with a PHP contact form. It works fine but I want it to validate HTML 4.01 Transitional. The validator looks down the html and stops at the

<?php
require_once('form/formmailer.php');
?>

It says that it validates, but when you look at the html that it checked the form and below is gone. It doesn't seem to miss the closing </body></html> tags at all.

I cleaned the code so it could be posted and this validates.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Contact Us</title>
<META NAME="keywords" CONTENT="stuff">
<META NAME="description" CONTENT="a form for contact us">
</head>
<body>
<div id="top"><a href="index.php"><img src="images/banner.jpg" width="600" height="150" border="none" alt="Logo"></a>
</div>
<div id="left">
<div>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="contact-us">Contact Us</a></li>
</ul>
</div>
</div>
<div class="content">
<h1>
Contact Us
</h1>
<p>
Use the contact form below.
</p>
</div>

I thought that the Javascript used to check the form fields might be the culprit, but I can't see how.

encyclo

1:33 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you uploading a local file to the validator? If so, the php won't be parsed. You need to validate the file on the server, where the page will delivered with the form included.

The validation result of the snippet you posted is not an error. It is a little-known fact that </body> and </html> are optional in HTML (but required in XHTML).

bumpaw

1:54 pm on May 13, 2004 (gmt 0)

10+ Year Member



Are you uploading a local file to the validator?

I gave the validator the URL of the page on the server. The browser source code looks fine and the page works except the validator can't see the PHP form and below. What I posted was what the validator saw.

ergophobe

3:27 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Based on what you said:
- you tried this multiple times with the same result.
- the page looks fine in a browser.

Did you look at "view source" on the validator output? I wonder if the there's something there, but it's hidden because though valid it's completely different from what you expect, though I would think that the validator would be set up to expect weird output.

bumpaw

3:39 pm on May 13, 2004 (gmt 0)

10+ Year Member



Mystery Solved! Life is too complex. The form in question has an anti spam feature that prevents access by direct linkage to the URL. You have to arrive on that page via internal site links to see the form. The form script is deliberately invisible to the validator and that gives a PHP exit that stops reading of the code below.