PHP:回声验证消息

I have a form in 'index.php' in wich I will validate some text fields using 'submit.php', if everything is ok it should insert the fields into my database using 'submit.php'. Now, if 'submit.php' detects an error it should echo the errors I stored in an array under my form at 'index.php':

INDEX.php :

<form action="submit.php" method="POST">
<input type="text" name="email" />
<input type="text" name="url" />
<input type="submit" name="Submit" value="Continue"/>
</form>
<div class="errorsgohere"><?php //WHAT TO ADD HERE? ?></div>

SUBMIT.php :

if(isset($_POST['Submit'])) {
  //I validate everything... etc..
  if(!empty($errors)) {
     echo "<div class='errors'>";
     foreach($errors as $error) {
         echo $error;
     }
     echo "</div>";
    } else { SubmitDatabase(); //If there are no errors it will proceed }
}

How can I echo what I have in $error BUT in INDEX.php inside my and if possible without refreshing the whole page? Thanks in advance!

you can use AJAX to send whatever values and then update your elements by the result:

...on HTML

<form id="formid" action="submit.php" method="POST">

...on javascript

...
$("#formid").submit(function() {
    var r = $.ajax({url:"submit.php",type:"POST",async:false,data:$("#formid").serialize()}); 
    var result = JSON.parse( r.responseText );
    // result["error"] should have the 1 you set in PHP
    // now update your elements
});

...on PHP (at the end)

...
// process your $_POST values you sent via AJAX and decide the result
...
echo json_encode( array("error"=>1, ...) );