Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post How to make a comment form?

    Hi everyone! I would like to know what I need to put a comment box on my webpage which is sorta like a blog but it doesn't have a link where people can post comments after each entry.

    I'd like to make the comment box similar to what blogspot has where someone can fill in their information (e-mail, homepage, etc) and post comments that will appear under the blog entry. I've searched all over google and still do not know what is required other than setting up a mysql database to store the comments. If anyone has any experience with this or any helpful information to share I'd greatly appreciate it!

    Thanks in advance

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    104
    Thanks
    7
    Thanked 2 Times in 2 Posts
    If you are just looking to see what's required, basically I'd say just a MySQL database ad the PHP script to add/view the comments.

    What you will need to consider though, is how to link the comments to the blog post. Is it third party software or self made? Either way, you'll need to see how the blogs are identified in the database (usually an id of some sort), and make a field for that in the comment table to identify the comments with the blog itself.

    Hope that helps

  • #3
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    659
    Thanks
    31
    Thanked 100 Times in 94 Posts
    It does depend on what system you are using for your blog. If you use your own just ensure that when your form is submitted it also includes the blog post's ID number for your mySQL database. You could do it any number of ways, this is one easy one:

    Code:
    <form action='myCommentScript.php' method='post' enctype='text/plain'>
    
    <input type='hidden' name='myBlogPostIDNumber' value='<?php echo( $thisPostsIDNumber ); ?>' />
    
    <input type='text' name='myFunCommentLine' />
    
    <input type='submit' value='Submit!' name='submit' />
    
    </form>
    Then read in the $_POST['myBlogPostIDNumber'] on your PHP page. CAUTION: If you use this method be sure to validate that this post actually exists in your database before storing them comment. Someone could utilize XSS and change the value of that hidden field to something malicious.

    Hope this gives you some more guidance.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  • #4
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I came across the Scripts Mill comment script but I have not installed it yet. On the demo page (http://www.scriptsmill.com/comments_demo.html) it says I need to have SSI: <!--#include virtual="/comments/comments.php" --> on every page that I want to have the comments system included. I do not understand what Server Sides Includes do. Please let me know what this means. Does this mean I need to insert that code on the bottom of each blog entry when I am coding so people can be able to comment on my posts?

    I am not using a blog but am setting up a web page that has blog entries similar to an actual blog, but it does not have a comments system yet.

    Thanks for the advice everyone!
    Last edited by c0den00b; 03-22-2009 at 06:00 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •