Error message for required field always showing
<p>I have an error for a required field, but even when it has been filled in, its showing my error message, maybe I need an else statement but not exactly sure.</p>

<pre><code>session_start();
// this sets variables in the session
$id = $_SESSION['user_id'];
foreach($_POST as $key =&gt; $value)
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$err = array();
$result = mysql_query("SELECT `id` FROM users WHERE `banned` = '0'") or 
die  (mysql_error());

if(empty($_SESSION['$user_id']))  // user not logged in; redirect to somewhere else
if (!empty($_POST['doThesis']) &amp;&amp; $_POST['doThesis'] == 'Save')
{
    $result = mysql_query("SELECT `id` FROM users WHERE `banned` = '0'") or 
die (mysql_error());


 list($id) = mysql_fetch_row($result);

 if(empty($abstract))
 {
 $err[] = "ERROR - Enter Abstract";
 //header("Location: thesis.php?msg=$err[0]");
 }
 /// Automatically collects the hostname or domain  like example.com)
 $host  = $_SERVER['HTTP_HOST'];
 $host_upper = strtoupper($host);
 $path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');

if(empty($err)) {
        for($i = 0; $i &lt; count($_POST["other"]); $i++)
        {
            $thesis_Name = mysql_real_escape_string($_POST['thesis_Name'][$i]);
            $abstract = mysql_real_escape_string($_POST['abstract'][$i]);


$sql_insert = "INSERT into `thesis`
     (`user_id`,`thesis_Name`,`abstract`  )
VALUES
     ('$id','$thesis_Name','$abstract' ";

 mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
        }

 header("location: myaccount.php?id=" . $_SESSION['user_id']. "");
}
</code></pre>

<p>}
Obviously the second header is where it should go when data is in the box. If I include the first header, the error message is in the URL bar where when I don't include the header line it is on the page (where it should be) help!!</p>

<p>I mean when I get an error it is the error I have set up, 'enter abstract' is displayed all the time, even when something is entered.</p>
