How to mantain values if submit fails PHP
<p>I have a form that is being validated using PHP server side scripting. The form's action is also to itself. To show multiple errors, I store it in an array and used foreach to loop through the values and echo it for dislay. I thought i'm finished using PHP validation but I noticed that everytime I submit the form, even though it still contains some errors, all of the values that were inputted resets. Why? When I used javascript, the values remains so whats with PHP?</p>

<p>This is how I set my errors and insert data to db.


<pre><code>if(isset($_POST["submit"]))
{
$lname = $_POST["lname"];

$errors = array();

if(strlen($lname) == 0)
{
$errors[] = "Last name is required";
}

if (!empty(errors))
{
//display errors using foreach loop
}
else
{
//connect and insert data to mysql db
}

}
?&gt;
</code></pre>
