title: Email Notification on new MySQL database entry
body: <p>I've been creating a blog using tutorials around the web and I have a working comments system but what I would like is if when the user adds a comment that I get an email. I'd really love if you could explain how exactly I could go about implementing a notification. Any help is greatly appreciated.</p>
  
  <p>Current Form:</p>
  
  <pre><code>&lt;form id="commentform" method="post" action="process.php"&gt;
  
  &lt;p&gt;&lt;input type="hidden" name="entry" id="entry" value="&lt;?php echo $id; ?&gt;" /&gt;
  
  &lt;input type="hidden" name="timestamp" id="timestamp" value="&lt;?php echo $commenttimestamp; ?&gt;"&gt;
  
  &lt;input type="text" name="name" id="name" title="Name (required)" /&gt;&lt;br /&gt;
  
  &lt;input type="text" name="email" id="email" title="Mail (will not be published) (required)" /&gt;&lt;br /&gt;
  
  &lt;input type="text" name="url" id="url" title="Website" value="http://" /&gt;&lt;br /&gt;
  
  &lt;br /&gt;
  &lt;textarea  title="Your Comment Goes Here" name="comment" id="comment"&gt;&lt;/textarea&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" /&gt;&lt;/p&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>Process.php:</p>
  
  <pre><code>&lt;?php
  if (isset($_POST['submit_comment'])) {
  
      if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comment'])) {
          die("You have forgotten to fill in one of the required fields! Please make sure you submit a name, e-mail address and comment.");
      }
  
      $entry = htmlspecialchars(strip_tags($_POST['entry']));
      $timestamp = htmlspecialchars(strip_tags($_POST['timestamp']));
      $name = htmlspecialchars(strip_tags($_POST['name']));
      $email = htmlspecialchars(strip_tags($_POST['email']));
      $url = htmlspecialchars(strip_tags($_POST['url']));
      $comment = htmlspecialchars(strip_tags($_POST['comment']));
      $comment = nl2br($comment);
  
      if (!get_magic_quotes_gpc()) {
          $name = addslashes($name);
          $url = addslashes($url);
          $comment = addslashes($comment);
      }
  
      if (!eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
           die("The e-mail address you submitted does not appear to be valid. Please go back and correct it.");
      }
  
      mysql_connect ('localhost', 'root', 'root') ;
      mysql_select_db ('ultankc');
  
      $result = mysql_query("INSERT INTO php_blog_comments (entry, timestamp, name, email, url, comment) VALUES ('$entry','$timestamp','$name','$email','$url','$comment')");
  
      header("Location: post.php?id=" . $entry);
  }
  else {
      die("Error: you cannot access this page directly.");
  }
  ?&gt;
  </code></pre>