At first, you are going to have to use Javascript and AJAX. And why don't you use a javascript library like Jquery?
Assuming you are going to use it, the code goes like this.
HTML:
<form id="yourForm">
<label for="name">Name</label>
<input id="name" name="name" type="text" />
<input class="submitBtn" type="submit" value="OK"/>
</form>
Javascript:
$(document).ready(function(){
$('#yourForm').submit(function(event){
$('.submitBtn').attr('value','MESSAGE SEND');
setTimeout(function(){
$('.submitBtn').attr('value','OK');
}, 3000);
var stuff = $('#yourForm').serialize();
jQuery.ajax({
type: 'POST',
url: 'your_php_code.php',
data:{
'stuff':stuff,
}
,success: function( response ){
alert('OK');
}
});
//Prevents form submission
return false;
});
});
PHP
<?php
parse_str($_POST['stuff']);
mail("youremail@gmail.com", "subject", $name);
?>