How Do You Get PHP to Have a Separate Line for an Input Field in a Submit Form?

Problem scenario
In a PHP "submit form" you have various fields.  Two of the fields are on the same row.  That is, when you open the page with a web browser, two input box fields are the same distance from the top and bottom of the page.  You want each field to be on its own line.  How do you do you get the PHP form to render the way you want?

Possible solution
This problem can be caused by a missing ">".  

Field3 and Field4 in this example below (<html> to </html>) would appear on the same row when the below is saved as a .php file and viewed with a web browser:

<html>
<body>

<form action="cool.php" method="post">
Field1: <input type="text" name="field1"><br>
Password: <input type="password" name="password"><br>
Field3: <input type="text" name="field3"<br>
Field4: <input type="text" name="field4"<br>

<input type="submit">
</form>

</body>
</html>

Note the lack of a closing ">" on the "Field3" line.  On the Field3 line before the "<br>", there is no ">".  This code below will put Field3 on a different line from Field4:

<html>
<body>

<form action="cool.php" method="post">
Field1: <input type="text" name="field1"><br>
Password: <input type="password" name="password"><br>
Field3: <input type="text" name="field3"><br>
Field4: <input type="text" name="field4"<br>

<input type="submit">
</form>

</body>
</html>

Leave a comment

Your email address will not be published. Required fields are marked *