showing a successful alert message after sending an email
<p>This is an email sending code</p>

<pre><code>mail($ToID,$subject,$urltoemail,$headers);
</code></pre>

<p>after sending, the user is redirected</p>

<pre><code>header("Location:".$_SERVER['SCRIPT_NAME']);
</code></pre>

<p>I have to show an alert of "mail has been send successfully" in the redirected page. How can I?</p>

<hr>

<p>Excerpt of code:</p>

<pre><code>if(isset($_POST['submitbtn'])) {
  $flag=true; $error="";
  /*Getting Values**********************/
  $ToID=$_POST['ToID'];
  $fromID=$_POST['fromID'];
  $subject=$_POST['subject'];
  $URL=$_POST['URL'];
  $message=$_POST['message'];
  /*Validating the data*****************/
  if(strlen($ToID)==0) {
    $flag=false;
    $error.="Enter To email address field";
  } elseif(!preg_match_all("|^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$|U", $ToID, $arr)) {
  $flag=false; $error.="Invalid To email address";
  }

  if($flag) {
    $urltoemail = "&lt;html&gt;&lt;head&gt;&lt;title&gt;Forgot Password&lt;/title&gt;&lt;/head&gt;&lt;body&gt; &lt;table&gt;&lt;tr&gt;&lt;td&gt;".$message."&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href='{$URL}'&gt;Click here for viewing map&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;";
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
    if(strlen($fromID)==0)
        $fromID = 'info@cimaps.co.uk';
    $headers .= 'From: '.$fromID. "\r\n";
    mail($ToID,$subject,$urltoemail,$headers);
    //$_SESSION['m'] = "item successfully deleted";
    header("Location:".$_SERVER['SCRIPT_NAME']);
  }
}
</code></pre>
