Passing php form validate error message back to submit form
<p>I'm trying to pass an error message from a server side form validator in a function back to the form it was submitted in. The validator is working as it prevents the rest of the code saving it to a database as planned. However I cant get it to pass back to the form to display the error</p>

<pre><code>function saveComment(){
    $validate = array();
    $id = isset($_POST["articleId"]) ? $_POST["articleId"] : '';

    if ( isset( $_POST['saveChanges'] ) ) {

    if ( $_POST['name'] == "" ){
         $validate['errorMessage'] = "Please fill out your name.";
      header( "Location:".HOME_PATH."/.?action=viewArticle&amp;articleId=".$_POST['articleID']."");
    }
</code></pre>

<p>I' trying to pass it back to this</p>

<pre><code>if ( isset( $validate['errorMessage'] ) ) {
    echo $validate['errorMessage'];
} 
</code></pre>

<p>When I remove the <code>if</code> on the display function I get the error <code>unidentified index</code></p>

<p>What do I need to do to get the form to display the error message. Do I need to pass the array to the function that handles the display of the article?</p>

<p><strong>FEEDBACK</strong></p>

<p>For anyone that may find this useful I used @OliverBS post method pretty much unaltered. </p>

<p>Also thank you to @lethal-guitar as he explanation has helped me understand where I went wrong and the various methods that can be used to solve this problem +1</p>
