Ho creato un form dove in base all'errore esce un messaggio di errore ed alla fine se va tutto bene scrive affianco al pulsante send che il messaggio è stato inviato, il mio problema è che anche se esce un errore correttamente se un campo è vuoto o non valido alla fine mi scrive sempre messaggio inviato ecco il codice
Codice PHP:

<?php
function is_email($email_to_test)
    {
        
$re  "^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])";
        
$re .= "+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$";
        if (
ereg($re$email_to_test))
        {
            return 
TRUE;
        }
        else
        {
            return 
FALSE;
        }
    }

$error = array();
$good = array();
$name $_POST['name'];
$email $_POST['email'];
$subject $_POST['subject'];
$comments $_POST['comments'];
if(isset(
$_POST['submit']))
    if(
$name == ""){
    
$error[0] = "Name is Required";
    
    }
    if(
$email == "" && (is_email("$email") != TRUE)){
        
$error[1] = "Please Insert Valid Email";
        
    }
    if(
$subject  == ""){
        
$error[3] = "Please Insert a Subject";
        
        }
    if(
$comments  == ""){
        
$error[4] = "Please Leave a Comments";
        
}else{
$to "myemail@email.com";
$headers "From: ".$name." <".$email.">\r\n";
$headers .= "Reply-To: ".$email."\r\n";
$headers .= "Return-Path: ".$email."\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if(
mail($to$name$comments$headers)) {
    
$good[0] = "Message Send";
}else{
    
$error[5] = "Error!! Please Resend ";
}
}

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css" >
<title>Contact</title>
</head>
<body>
<div id="container">
        <div id="menu">
            <ul id="inlinemenu">
                [*][url="index.html"]Home[/url]
                [*][url="#"]Company[/url]
                [*][url="#"]Articles[/url]
                [*][url="#"]About Me[/url]
                [*][url="contact.php"]Contact[/url]
            [/list]
        </div>
    <div id="wrap">
        <div class="index-left">
            <div class="logo">
                [img]images/logo.png[/img]
            </div>
            <div class="content">
            <div id="form_box">
                <form action="contact.php" method="POST" id="form-box">
                    <fieldset>
                        <legend class="n1">Your contact information</legend>
                            <label>[b]Name:[/b]</label>(required)

                                <input type="text" name="name" value=""  /><?php echo $error[0]; ?>
                
                                <label>[b]E-mail:[/b]</label>(required)

                                <input type="text" name="email" value="" /><?php echo $error[1]; ?><?php echo $error[2]; ?>

                                <label>[b]Subject:[/b]</label>(required)

                                <input type="text" name="subject" value="" /><?php echo $error[3]; ?>

                                

                    </fieldset>
                    <fieldset>
                        <legend class="n1">Your message</legend>
                            <label>[b]Message:[/b]</label>(required)<?php echo $error[4]; ?>

                                <textarea name="comments" rows="7" cols="50" ></textarea>
                                

                                <input class="button" name="submit" type="submit" value="Send" /><?php echo $error[5]; ?><?php echo $good[0]; ?>
                    </fieldset>
            </div>
            </div>     
        </div>
        <div class="index-right"> 
    
        </div>


        <div id="footer">
            <ul id="footer-menu">
                [*]Build By [url="http://www.newstyles.it"]newstyles.it[/url]
                [*][url="#"]Valid Html[/url]
            [/list]
        </div>
    </div>


</div>
</body>
</html>
Vorrei che se se esce un errore per un campo vuoto non uscisse message send alla fine