mandatory field error
<p>I'm having serious trouble displaying my error message if a field isn't complete.
I want the error message to show when the abstract is left empty but if its filled in, I want the submit button to go to their account page (in session)
PHP:</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();


if(empty($_SESSION['$user_id']))  // user not logged in; redirect to somewhere else
if (!empty($_POST['doThesis']) &amp;&amp; $_POST['doThesis'] == 'Save')
{

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


/// 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)) {

 $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());
}

else{

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

<p>In the HTML:</p>

<pre><code>&lt;script&gt;
$(document).ready(function(){
$.validator.addMethod("abstract", function(value, element) {
return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
}, "Thesis.");
$("#regForm").validate();
});
&lt;/script&gt;

&lt;?php
if(!empty($err))  {
echo "&lt;div class=\"msg\"&gt;";
foreach ($err as $e) {
echo "* $e &lt;br&gt;";
}
echo "&lt;/div&gt;";
}
?&gt;
</code></pre>

<p>If you need any more information, please let me know as I need to get this working!</p>
