First off, you need to add a enctype to your form tag and add a name to your submit button (to be used for submission) like this
[html]
SendMail
[/html] And as long as this is the same file as you are posting to {sendeial.php} you can place something along these lines at the top of the page:
[php]
<?
if (isset($_POST['submitBtn']) && $_POST['submitBtn'] == 'Send Mail') {
$clean = array();
foreach( $_POST as $key => $val) {
$clean[$key] = htmlentities($val, ENT_QUOTES);
}
$to = 'you@yourdomain.com';
$headers = ""; // you can add Bcc and Cc addresses here
$subject = "You have a new subscriber to your site!\n\n";
$body = "Name: " . trim($clean['visitor']) . "\n";
$body .= "Email: " . trim($clean['visitormail']) . "\n";
$body .= "IP: " . $clean['ip'] . "\n" ;
$body .= "Referrer: " . $clean['httpref'] . "\n";
$body = "User Agent: " . $clean['httpagent'];
if ( !mail($ot, $subject, $body, $headers)) {
echo "There was a problem sending the email, i might want to write this to a flat file just in case"
}
}
?>
[/php]
You should always clean your input, this is why I do a foreach on the post data and run it through htmlentities(). This is a bare minimum, you might also want to add some error detection in case the email is mal formatted or there were some empty fields.
I also wrapped the mail function call in a if statement so you can handle a failure gracefully. You will need to make sure you can send emails on youre server.
I didnt try to run this code, so there might be some syntax errors in there, I got fat fingers sometimes. You will need to play with it for your specific deployment.
This should be enough to get you going. Good luck
Sn4rf3r