BLOG DESIGN (Web server application) SOLUTIONS } ?> Name: Email: Website:
BLOG DESIGN SOLUTIONS } ?>
Name:
Email:
Website:
Comment:
Now add the following script to the end of the PHP code (just before the closing ?> delimiter) at the top of your document: // If comment has been submitted and post exists then add comment to database if (isset($_POST[”postcomment”]) != “”) { $posttitle = addslashes(trim(strip_tags($_POST[”posttitle”]))); $name = addslashes(trim(strip_tags($_POST[”name”]))); $email = addslashes(trim(strip_tags($_POST[”email”]))); $website = addslashes(trim(strip_tags($_POST[”website”]))); $comment = addslashes(trim(strip_tags($_POST[”comment”]))); $sql = “INSERT INTO comments (post_id,name,email,website,comment) VALUES (’$post_id’, ‘$name’, ‘$email’, ‘$website’, ‘$comment’)”; $result2 = mysql_query($sql); if (!$result2) { $message = “Failed to insert comment.”; } else { $message = “Comment added.”; $comment_id = mysql_insert_id(); // Send yourself an email when a comment is successfully added $emailsubject = “Comment added to: “.$posttitle; $emailbody = “Comment on ‘”.$posttitle.”‘”.”\r\n” .”http://www.your-domain-name.com/post.php?post_id=”.$post_id . .”#c”.$comment_id.”\r\n\r\n” .$comment.”\r\n\r\n” .$name.” (”.$website.”)\r\n\r\n”; $emailbody = stripslashes($emailbody); $emailheader = “From: “.$name.” <".$email.">\r\n”.”Reply-To: ” . .$email; mail(”you@your-domain-name.com”, $emailsubject, $emailbody, . $emailheader);