text box value disappears/empties on PHP validation
<p>Hi I have a structure as follows. The issue is once the error message is displayed, the text box content disappears and need to re-type a value again. I need to retain the original text box value/content as it is whilst the message is displayed. How do you think I should change? Thanks.</p>

<pre><code>    &lt;?php 
if(isset($_POST['subN'])) {
$InNo = $_POST['invc_no'];

$MSG = '';
if($InNo == "") 
{$MSG = 'Invoice number is required';} 
else
{//some code to save data to a database}
?&gt;

&lt;!DOCTYPE html&gt;
&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;form method="POST" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
&lt;div id="msgBox"&gt;&lt;?php if(!empty($MSG)) echo $MSG; ?&gt;&lt;/div&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="text" id="invc_no" name="invc_no" size="15" class="colr" value="&lt;?php htmlentities('InNo')?&gt;"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="submit" name="subN" id="subN" value="Save"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
