Search
Left Quote    Wise men speak because they have something to say; Fools because they have to say something.
- Plato (427-347 B.C.)    
Right Quote
 
[login] | [Register]
 

Building a Comments Script

by: bs0d
Page: 4 of 4
(View All)

Displaying the Form


We are nearing the end, and this is our last portion of code. Under the condition that checks if the submit button is pressed, this is our "else" part. Its not pressed, so we display the form. Here is the first part:



In the code above, you see the else part of the condition to begin displaying the form, and the html which starts the form and where we declare our hidden fields. We have three hidden fields: page, date and time. These fields are not shown to the user, we use them internally to get that data. The data is inserted in the value property with PHP.

Displaying the Form Continued...


This is the rest of the form, which goes immediatley under the code displayed above. It is simply a table with form elements for the user to input data. Again, you can add colors and formatting later, this is basically what you will need.


Conclusion


You can cut and paste each of all the code sniplets within this tutorial, or you can get the entire script from the code samples area. To view it, follow the link below:

Comments Script Code

There we have it. I've walked you through step by step of creating a comments system for your website. With this comments script, it is run easily through a database, and can have comments on countless pages. If you have a users system, then it will be very easy for you to see if they're logged in and display their member name in the username field. I hope this tutorial has served you well! Enjoy-

bs0d | www.allsyntax.com

1  |  2  |  3  |  4  |  


Comments:

  gravy
  Subject: "Awesome" Date: Mar 08 2007 at 5:27 pm    

I ca't wait to digg into this code work ow that I have read the tutorial! Great job!
  curious
  Subject: "reverse order; queuing posts" Date: Sep 06 2007 at 8:25 am    
I will be re-reading more carefully to see if you discuss this, but am interested to know whether the posts can be shown in reverse order (latest post first) and whether the posts can be held in queue and be made live only after the moderator has approved them.
  curious
  Subject: "Thanks" Date: Sep 06 2007 at 8:27 am    
Many thanks for the tutorial, by the way. I really appreciate it.
  bs0d
  Subject: "Sure Thing" Date: Sep 10 2007 at 12:41 pm    

You can change the order of the posts easy enough. Just change from ASC to DESC in the end of the query that grab's the posts (on page 2 of this article).

You can also hold them in "queue" simple enough. Add a column to the table, call it "verify" - you can set it up to be enum ('yes', 'no') with default as no. Then, when you query, query all where verify = yes.

You can make moderators able to see all posts (yes or no), just execute a different query if they're logged in and are moderator. Add a link in the corner of unverified posts that only moderators can see to verify the posts. That link would be to a script that updates the verify column for the post from no to yes.
  chinako
  Subject: "MySQL" Date: Sep 26 2007 at 10:18 pm    
I love this! As a brand newbie to PHP I find this code and its breakdown to be very helpful.

My question lays within the use of MySQL to get this code functioning properly. As my host does support PHP I asked them about MySQL and they told me that I would need a MySQL database for it, as they don't have one. Is the one we are building with this code all I need, or do I need a "database" that is its own code?

Thank you for taking the time to answer my question! Again, I'm brand new to PHP and MySQL, so I apologize for this if it seems simple.
  bs0d
  Subject: "Database Required" Date: Sep 27 2007 at 7:27 am    

Yes, you need a database. This article talks about creating a table IN the database, so they would need to install mySQL. Actually, it's very rare for a hosting company to have PHP and not MySQL or any other database available.
  chinako
  Subject: "Code Goes Where" Date: Sep 27 2007 at 9:09 am    
Thank you! I'll look into the database issue.

Another question I have is simply where do I put this code? Does it need to go within the HTML pages that require comments? Or is there a link I can add to every blog entry that would point to the comment PHP code as its own page, thus giving me comments for each blog?

Also, how do I tell the code which comments go to which entry? Is there a space for me to program dates of entries so that the comments only show up for the entry they are about?

Again, sorry for so many questions. But thank you very much for your help!
  bs0d
  Subject: "Check the Forums or Search" Date: Sep 27 2007 at 9:54 am    

You can check the fourms, or use the search feature in the top-right corner of the site.

Here is a topic that answers your question: PHP Comments Script Question
  chinako
  Subject: "Thanks Again!" Date: Sep 28 2007 at 10:38 am    
Thank you SO much! You are a wonderful help and I really appreciate that you took the time to type all this out as well as answer questions.

Have a GREAT day!
  PyroCandy
  Subject: "Getting Errors" Date: Mar 07 2008 at 8:29 pm    
I could use some help once again . . .

I have the db created in mySQL and put the script code into my page . . .but when I try to load the page it give me a PHP error message right on the page.

pyrocandy.890m.com/comments.php

plz and ty for all your help
hope to hear from you soon
  jyogit
  Subject: "help needed" Date: Mar 19 2008 at 4:02 am    
well ive created the dbase and copied and pasted the code.
on the final full code u have ommited the first line of the connect once code....

i cant get this to work at all.

am i missing something?
  cefx
  Subject: "customize" Date: Jun 19 2008 at 1:53 pm    
is there anyway i can customize the out come of the comment... i.e. wat it looks like?


  bs0d
  Subject: "Yes" Date: Jun 19 2008 at 7:35 pm    

Yes, the outcome of the comment is up to your creativity with HTML/CSS.
You Must be logged in or a member to comment.


Tutorial Stats

Tutorial Stats

95,305 Views
19 Total Comments
4.5 Rating of 5 (2 Votes)

Options

Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Del.icio.us: Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article

Articles

Related    

· Simple PHP Tutorial
· One File Website
· Pagination with PHP
· Complete Members System
· Variable Scope


Share Dealing - Car Insurance - Renegade Motorhomes - Best Credit Cards

"AllSyntax.com" Copyright © 2002-2007; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank