Something like this would work as a starting point:
<form action="" method="post">
<input type="submit" value="Send details to embassy" />
<input type="hidden" name="button_pressed" value="1" />
</form>
<?php
if(isset($_POST['button_pressed']))
{
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>
UPDATE
This can be used as a Javascript function to call the mail.php page and send the email without reloading the page.
function sendemail()
{
var url = '/mail.php';
new Ajax.Request(url,{
onComplete:function(transport)
{
var feedback = transport.responseText.evalJSON();
if(feedback.result==0)
alert('There was a problem sending the email, please try again.');
}
});
}
You'll need Prototype for this method: http://www.prototypejs.org/api/ajax/request
I haven't tested this, but hopefully it should be along the right lines.