Something like this should work for you, you'll just need to tweak it a bit to fit your current code:
PHP Code:
<?php
$myEmail = 'youremail@here.com';
if(!isset($_POST['email']) || empty($_POST['email'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="text" name="email"/>
<input type="submit" value="Send">
</form>
<?php
}
else{
if(@mail($myEmail,'Email from your site', $_POST['email'])) { // If it fails to send, the @ sign stops errors from being displayed
echo 'Your email address has been sent to the website admin';
}
else {
echo 'Failed to send your email address, please try again later.';
}
}
?>
That should do what you want, but of course you'll have to add in some validation for the email address but I'm sure you can find more about that on google.
Hope this helps.
Bookmarks