Why does PHP not output class="error" in the <td> tag when the $vorname field is left empty?

The issue is that the conditional check for empty $vorname field is using the wrong comparison operator. Instead of checking if $vorname is empty, it is checking if it is equal to an empty string, which may not always be the case. To fix this, the condition should use the empty() function to check if $vorname is empty or not.

&lt;td &lt;?php if (empty($vorname)) { echo &#039;class=&quot;error&quot;&#039;; } ?&gt;&gt;&lt;?php echo $vorname; ?&gt;&lt;/td&gt;