The following is the source code I'm working on, it seems that when I insert a fake email that isn't in my database, the error message is should just fine, but than, after I insert another fake email, no error this time, even when I put in the valid email.

When I first fill in with a valid email (valid msg shown) and then another valid\invalid email, nothing happens.

What had I go wrong?

PHP Code:
<html>
<body bgcolor=white>


<?
if ($Submit == "Submit") {              // If form has been submitted
        
$errormsg = array();


        if (!
$email)
        {
                
$errormsg[] = "Please fill in your email address";
        }


        
$count count($errormsg);

        
#echo $count."<br>";

        
if ($count 0) {
                for (
$i=0$i<count($errormsg); $i++) {
                        echo 
$errormsg[$i]."<br>";

                }

        }

        elseif (
$count == 0)
         {
                
#Insert Database checking ( NO ERROR )

                        
$host="localhost";
                        
$dbuser="root";
                        
$dbpassword="root";

                                
mysql_connect($host$dbuser$dbpassword) or die ("Unable to Connect to Database");
                                
mysql_select_db("secretDB");
                                
$query "Select username,password from users where email = '$email'";
                                
$sqlquery mysql_query($query);
                                
$num mysql_numrows($sqlquery);

                                if (
$num == 0#Not valid
                                
{
?>
                                        <center>So sorry, your email is not valid.</body></html>
<?


                                
}
                                else if (
$num == 1#Valid
                                
{
                                
?>
                                <center>Sent mail.</body></html>


                                <?

                                
}

                        }










}
if (
$reset == "Reset"){
        
$username "";
        
$real_name "";
        
$password "";
        
$email "";
}


?>

<form name="form1" method="post" action="<? echo "$PHP_SELF"?>">
  <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b>Lost
    Password ?</b></font><br>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Fill in your email
    in the following inputbox and receive your email via password</font> <br>
    <input type="text" name="email" size="40">
    <br>
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Submit2" value="Reset">
  </div>
</form>



</body>
</html>