First, you set $name, $email and $comments, and then, you check if they are set... they will ALWAYS be set !
You mixed up subject and message... subject should be "Comment from viewer", and message, the other thing...
Also, you call exit OUTSIDE your if statement, so it will always exit !
Maybe something like this :
<?php
if(isset($_POST['submit']) && isset($_POST['name']) && isset($_POST['name']) && isset($_POST['comments']))
{
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$comments = trim($_POST['comments']);
if(($name == '') || ($email == '') || ($comments == ''))
{
echo 'At least one of the fields is empty.';
}
else
{
$to = 'email@email.com';
$subject = 'Comment from viewer';
$message = "$name commented on your Blogging site\r\nHis email address is: $email \r\nHe had this to say: $comments";
if(mail($to, $subject, $message))
{
echo 'Email sent successfully.';
}
else
{
echo 'Email couldn\'t be sent.';
}
}
}
else
{
echo 'At least one of the fields isn\'t set.';
}
?>