Reputation: 17
I keep getting an error message when trying to validate my coding for this form. Could someone run their eyes over it and see if you can pick up on something I haven't.
The error is coming from this line in my coding:
<?php if ($ContactID != '') { ?>
<input type="hidden" name="ContactID" value="<?php echo $ContactID ?>"/>
<?php } ?>
Actual coding:
<!-- Form-->
<form name="editcontact" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>">
<table border="1" cellpadding="2">
<caption>Edit Contact</caption>
<!--ID Input-->
<?php if ($ContactID != '') { ?>
<input type="hidden" name="ContactID" value="<?php echo $ContactID ?>"/>
<?php } ?>
<!--Name Input-->
<tr>
<td><label for="Name">Name</label></td>
<td><input type="text" name="Name" value="<?php echo $Name ?>" size="30" maxlength="50" tabindex="1"/>
</td>
</tr>
</table>
</form>
Upvotes: 0
Views: 1341
Reputation: 128776
input
isn't a valid child of the table
element. Your provided code will render:
<table>
<input type="hidden" ... >
...
</table>
You should either wrap this hidden input field within a td
or th
element, or move it outside of the table completely:
<table>
<tbody>
<tr>
<td>
<input type="hidden" ... >
</td>
</tr>
...
</tbody>
</table>
Or:
<input type="hidden" ... >
<table>
...
</table>
Upvotes: 2