<?php
// NOTE: This page should *not* be wrapped in html. Leave it as it is,
// with the exception of changing the email address here:
// specify an email address to send comments to (this should be your
// address)
$to="hide@address.com";
// include our db settings
include "db.inc";
// strip html and php tags from the name supplied
$name=strip_tags($_POST["name"]);
// if a name isn't given, make the name "Anonymous"
if ($name=="") {
$name="Anonymous";
}
// strip tags from the comment itself
$comment=strip_tags($_POST["comment"]);
// replace newlines with html linebreaks for the database
$commentmysql=str_replace("\n", "<br />", $comment);
// strip backslashes (used for escaping characters) from the comment so
// it can be use in the rss feed.
$comment=stripslashes($comment);
$entry=$_POST["post"];
$parent=$_POST["parent"];
// if the comment has no parent it must be a toplevel comment, so make
// its parent "0"
if ($parent == "") {
$parent=0;
}
mysql_query("INSERT INTO comments (poster, comment, entry, parent) VALUES ('$name', '$commentmysql', $entry, $parent)");
// specify the message that will appear in the email
$message="Comment from $name.\n\n$comments\n\n";
// actually send the email (this will only work on unix systems with
// an MTA installed, AFAICT)
mail($to,"Comment From $name",$comment,"From: $to\n");
// redirect the user back to the main blog page
header('Location: index.php');
?>