Validator doesn't like php form

I’m trying to move this site from transitional to a strict doctype and it doesn’t like this form (at least it didn’t throw an error until I added the form).

What should I be understanding?


echo '<form  action="see_cart.php" method="post">';
         echo '<input   type="hidden" name="user" value="' . $fn_upper . '" />';
         echo '<input type="submit" class="cart" value="See Cart"  />';
echo '</form>';

I get four errors:

Line 249, Column 565: document type does not allow element “INPUT” here; missing one of “P”, “H1”, “H2”, “H3”, “H4”, “H5”, “H6”, “PRE”, “DIV”, “ADDRESS” start-tag

Line 249, Column 566: character data is not allowed here

Line 249, Column 618: document type does not allow element “INPUT” here; missing one of “P”, “H1”, “H2”, “H3”, “H4”, “H5”, “H6”, “PRE”, “DIV”, “ADDRESS” start-tag

Line 249, Column 624: end tag for “FORM” which is not finished

here’s the link:

http://www.lincolnsr…111_debuger.php

Sounds like your HTML isn’t marked up correctly before or after the form itself as that looks perfectly valid, could you please re-post your link as it currently doesn’t work.

Inputs are meant to be wrapped in block level elements (though I’ve never figured out why).

<div>
<input   type="hidden" name="user" value="" />
<input type="submit" class="cart" value="See Cart" />
</div>

If you wrap the inputs in a div or fieldset or similar, some of those problems will go away. The link you gave is broken, though.

Sorry,

http://www.lincolnsrealdeals.com/temp111_debuger.php

You have a <p> around the submit button but not around the previous input. If you put a <p> around that too, the page will validate. I’d use a div instead, but it’s up to you:


<form  action="see_cart.php" method="post">
  [COLOR="#FF0000"]<p>[/COLOR]<input type="hidden" name="user" value="Eric">[COLOR="#FF0000"]</p>[/COLOR]
  <p><input type="submit" class="cart" value="See Cart"></p>
</form>

or

<form  action="see_cart.php" method="post">
  [COLOR="#FF0000"]<div>[/COLOR]<input type="hidden" name="user" value="Eric">
  <input type="submit" class="cart" value="See Cart">[COLOR="#FF0000"]</div>[/COLOR]
</form>

That worked ralph.m. Thank you very much.

I know you can’t know, but how could I not know that???

I’ve never wrapped inputs in a <p> before. Is there a ref for that? This is a pretty basic omission. It would be nice to get some idea how I missed that. Maybe it’s just the “strict” that forced the issue for me finally.

Yeah, it’s just a silly thing with form inputs that they need to be wrapped in some kind of block element to be “valid”. (They work fine with or without it.) I don’t see the point of it. Anyhow, yes, it’s probably a strict rule.

Thanks for the peace of mind. I don’t think I’ll forget that rule soon.

Thanks for your help ralph.m and chris.upjohn.