Forum Moderators: open
this is the original code:
<form method="post" action="login.php">
<div id="logmain">
<div id="loghead2"> <?php
if (!isset($_POST['submit'])) {
echo "Please insert your username and password to enter the Administration Panel";
} else {
echo "There was an error in the data you entered or some fields were left empty.";
}
?>
</div>
<div id="logfield">
<div class="loglabel">Username :</div>
<div><input id="loginput" name="username" type="text" id="username2"></div>
</div>
<div id="logfield">
<div class="loglabel">Password :</div>
<div><input id="loginput" name="password" type="password" id="password2"></div>
</div>
<div class="loglabel"> </div>
<div><input type="submit" class="button" id="logbutton" name="submit" value="login" border="0"></div>
</div>
</form>
And this is what is being processed by the W3C xhtml validator
17:<form method="post" action="login.php"><input type="hidden" name="PHPSESSID" value="c9eea6593fd8eeb25d6d83a9bd7fd8d7" />
18: <div id="logmain">
19:<div id="loghead2"> Please insert your username and password to enter the Administration Panel
20:</div>
21:<div id="logfield">
22:<div class="loglabel">Username :</div>
23:<div><input id="loginput" name="username" type="text" id="username2"></div>
24:</div>
25:<div id="logfield">
26:<div class="loglabel">Password :</div>
27: <div><input id="loginput" name="password" type="password" id="password2"></div>
28:</div>
29:<div class="loglabel"> </div>
30: <div><input type="submit" class="button" id="logbutton" name="submit" value="login" border="0"></div>
31: </div>
32:</form>
I'm using PHP + sessions
The error I get in validation is the following:
-->>> Line 17, column 120: document type does not allow element "input" here; missing one of "p", "h1", "h2", "h3", "h4", "h
5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag
...="c9eea6593fd8eeb25d6d83a9bd7fd8d7" />
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the
only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing
element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>")
inside an inline element (such as "<a>", "<span>", or "<font>"). <<<--
So the problem is the hidden input field containing the session ID.
How can I get this form to validate? My fear is that I will have similar problems with the other forms on my site.
I don't know much about xhtml, but are there some issues regarding the use of xhtml with forms, php etc...?
Thanks a lot to those who will help me.
I don't know enough PHP to understand why the session ID is getting inserted immediately after the <form> tag, but I believe that is the problem - in strict mark-up anyway. In transitional mark-up, <input> would be allowed without a container.