Thank you message or redirect after webform submitted
<p>I've posted this as an update to my previous question but I think it may be being missed.  Thanks to Andrey Mav and Devang Rathod for the responses.</p>

<p>I've realised where I have gone wrong now........I had the form action as 'form_mailer.php', which is not the form page itself but another page that performs further actions with the data provided on the webform.</p>

<p>I have now brought the 'form_mailer' coding into the webform .php and have changed the 'action' of the webform page so that it effectively submits to itself, but now I need to redirect to the form_mailer page following successful submission of the webform or display a thank you message........<strong>don't suppose anybody knows how I can do this?</strong> If you could provide instructions for how to do both that would be great as I can then choose the one I prefer that would be best for my needs.</p>

<p>Thanks again!</p>

<p><strong>[UPDATE]</strong></p>

<p>Here is the code:</p>

<pre><code>&lt;form action="webform.php" method="post"&gt;

&lt;table&gt;
&lt;tr&gt;&lt;td&gt;What is your name?&lt;/td&gt;
&lt;td&gt;&lt;input type="text" name="formName" maxlength="50" value="&lt;?=$varName;?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;     

&lt;tr&gt;&lt;td&gt;What is your occupation?&lt;/td&gt;              
&lt;td&gt;&lt;input type="text" name="formOccupation" maxlength="50" value="&lt;?=$varOccupation;?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;     
&lt;/table&gt;
&lt;input type="submit" name="formSubmit" value="Submit"&gt;
&lt;/form&gt; 

&lt;?php
if($_POST['formSubmit'] == "Submit") 
{   
$errorMessage = "";   

if(empty($_POST['formName']))   
{    
$errorMessage .= "&lt;li&gt;You forgot to enter your name!&lt;/li&gt;";  
}  
if(empty($_POST['formOccupation']))   
{    
$errorMessage .= "&lt;li&gt;You forgot to enter your occupation!&lt;/li&gt;";  
}   

$varName = $_POST['formName'];  
$varOccupation = $_POST['formOccupation'];   

if(!empty($errorMessage))   
{    
echo("&lt;p&gt;There was an error with your form:&lt;/p&gt;\n");    
echo("&lt;ul&gt;" . $errorMessage . "&lt;/ul&gt;\n");  
}  

}    
?&gt;

&lt;?php
if($errorMessage != "") 
{  
echo("&lt;p&gt;There was an error:&lt;/p&gt;\n");  
echo("&lt;ul&gt;" . $errorMessage . "&lt;/ul&gt;\n");
} 
else
{  
$fs = fopen("data.csv","a");  
fwrite($fs,$varName . ", " . $varOccupation . "\n");  
fclose($fs);   
}
?&gt;

&lt;?php

$emailSubject = 'Form submitted!';
$mailto = 'myemail@mydomain.com';

$formNameField = $_POST['name'];
$formOccupationField = $_POST['occupation'];

$body = &lt;&lt;&lt;EOD
&lt;br&gt;&lt;hr&gt;&lt;br&gt;
Name: $formName &lt;br&gt;
Occupation: $formOccupation &lt;br&gt;
EOD;

$headers = "From: $formName\r\n";
$headers .= "Content-type: text/html\r\n"; 
$success = mail($mailto, $emailSubject, $body, $headers); 
?&gt;
</code></pre>

<p>After the data has been checked, sent to the .csv and e-mailed to me (as per code above), I want the site to display a thank you massage to the user (either a thank you message on the same page or redirect to an alternative page that contains a thank you message).</p>

<p>Any help appreciated!......can't seem to get it to work!</p>

<p>Thanks.</p>
