Hey all, Im trying to put a submit news box on my admin page but for some reason my top box, Headline: "Textbox here", is not showing up on my page. Am I doing something wrong? Did I miss a tag somewhere?? Thanks in advance.

<tr>
    <td>
    <br>
    <!--Display Add News Box-->
    <h3>Add News</h3>
    <table>
    <form action="admin/adminprocess.php" method="post>
        <tr><td>
        Headline:<br>
        <input type="text" name="headline" maxlength="50" value="<?php echo $form->value("headline"); ?>">
        </td>
        <td>
        Date:<br>
        <input type="text" name="date" maxlength="8" value="<?php echo $form->value("date"); ?>">
        </td></tr>
        <tr><td>
        Content:<br>
        <textarea type="text" rows="6" cols="50" name="text" maxlength="50" value="<?php echo $form->value("text"); ?>"></textarea><?php echo $form->error("text"); ?><br>
        </td></tr>
        <tr><td>
        <input type="hidden" name="subnews" value="1">
        <input type="submit" value="Submit News">
        </td></tr>
    </form>
    </table>
    </td>
    </tr>
    <tr>
    <td><hr></td>
    </tr>

Dani AI

Generated

The symptom you described is almost always an HTML parsing problem (unbalanced quotes or invalid nesting) rather than a PHP logic bug. found a simple typo that caused the browser to treat the rest of the markup as part of an attribute; that kind of error is common. was right to suggest comparing the generated source, and is correct that form/table nesting must be valid.

Quick troubleshooting checklist

  • Compare the raw page source (View Source) with the DOM shown in the browser inspector (Elements panel). Browsers will rearrange or drop elements when HTML is malformed; the inspector shows the browser’s interpreted DOM.
  • Search the source for the input name to see if it exists but was swallowed into an unterminated attribute.
  • Run the page through the W3C validator to catch structural errors: W3C Validator.
  • If the element exists in the DOM but is invisible, inspect computed styles for display, visibility, opacity, width/height, z-index, and position to rule out CSS hiding or overlap.

Preventive fixes and best practices

  • Always escape dynamic values you insert into HTML attributes to avoid breaking quotes and to prevent XSS. In PHP use htmlspecialchars with ENT_QUOTES, for example:
<?php echo htmlspecialchars($value, ENT_QUOTES); ?>
  • Keep form/table nesting valid: put the form around the table or inside a table cell, not between table and tr. A simple valid layout (using labels for accessibility):
<form action="/path" method="post">
  <table>
    <tr>
      <td>
        <label for="headline">Headline</label><br>
        <input id="headline" name="headline" type="text">
      </td>
    </tr>
  </table>
</form>

Helpful references: MDN: form element, MDN: table element, and PHP: htmlspecialchars. These steps catch the vast majority of "input not showing" cases.

Recommended Answers

All 3 Replies

What does the code look like when you view-source in a browser ( i.e. after the PHP code has been executed ). Post the same code after PHP, and check to make sure those echos don't put invalid characters inside the value attribute.

Are you using an XHTML DTD, a HTML DTD, or no specified DTD? [ that code uses HTML tag closure rules, so you shouldn't use an XHTML DTD, a HTML DTD is preferable, but no DTD should work functionally ]

Try putting the form element outside the table element ( i.e. <form><table>..</table></form> rather than <table><form>..</form></table> ). Only certain things should go directly inside <table> elements ( tbody, tr etc )

EDIT: Oops; I didn't see the solved marker on this thread... How did you solve the problem in the end?

heh, bad typing on my part

<form action="admin/adminprocess.php" method="post>

should be:

<form action="admin/adminprocess.php" method="POST">

You have the table and form tags tangled.

The form tag must not be between table and its tr.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.