Echo Warning or Confirmation on Condition [PHP]
<p>What I expect on execution:</p>

<p>The function <code>Email()</code> will be called each time the page loads. If <code>$Valid</code> exists <code>Email()</code> should return either <em>true</em> or <em>false</em>. If <code>$Valid</code> does not exist <code>Email()</code> checks the <code>Postback()</code> (example: has the page been submitted and we're seeing it for the second time?) and if <em>true</em> <code>Validate()</code>s the form fields and either sets <code>$Valid=1</code> (for <em>true</em>) and sends <code>mail()</code> or sets <code>$Valid=0</code> (for <em>false</em>).</p>

<p>Now <code>$Valid</code> exists <code>Email()</code> should just return a <em>true</em> or <em>false</em> when called for the second time, say for example by a function to echo a warning or confirmation message if <code>mail()</code> successfully sent or not.</p>

<p>What's happening?</p>

<p><code>$Valid</code> isn't set it seems when <code>Email()</code> is initially called so when we call <code>Email()</code> a second time the <code>isset($Valid)</code> <code>if</code> clause always returns <em>false</em>.</p>

<p>I really hope you can help, I appreciate any answers and thank you all!</p>

<p>BTW: I know we could "<code>try</code>" and "<code>catch</code>" <code>mail()</code> too but I've cut down the complexity of the code as much as I can so it's easier to digest!</p>

<p>Here's the code I need help with:</p>

<pre><code>function Validate(){
    if(!empty($_POST["From"])&amp;&amp;!empty($_POST["Body"])){
        return true;
    }else{
        return false;
    };
};
function Postback(){
    if(isset($_POST["Return"])){
        return true;
    }else{
        return false;
    };
};
function Email(){
    if(isset($Valid)){
        if($Valid!=0){
            return true;
        }else{
            return false;
        };
    }else{
        if(Postback()){
            if(Validate()){
                $Valid=1;
            }else{
                $Valid=0;
            };
        };
    };
};
Email();
</code></pre>
