simple comment box ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nits4u
Forum Newbie
Posts: 15
Joined: Tue Jun 23, 2009 3:44 am

simple comment box ??

Post by nits4u »

i want to add a simple comment box on each page with some basic text editing features(optional) which first asks for the name of person so that any visitor can post their comment. And also i don't want to save the comments in Db. they shows immediately after posting (like mostly in blogs).

Thank You.
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: simple comment box ??

Post by jazz090 »

well most blogs use a DB and by most i mean all of them
User avatar
juma929
Forum Commoner
Posts: 72
Joined: Wed Jun 17, 2009 9:41 am

Re: simple comment box ??

Post by juma929 »

Hello,

There is an alternative by writing to text file, but your getting yourself into more hassle than its worth. If your going to allow your users to store information, store it properly, use a database.

Thanks.
nits4u
Forum Newbie
Posts: 15
Joined: Tue Jun 23, 2009 3:44 am

Re: simple comment box ??

Post by nits4u »

ohk.........
thanks alot for ur concern....

now can u provide d code for that ?
actually i also want basic word editing functions in it (if possible !!!)

thank you again
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: simple comment box ??

Post by a94060 »

another alternative would be to allow people to post html. You could then remove certain harmful takes, or do the reverse and allow only certain tags. Also,use a database, you could make a table for each page(not worth it) ,or just put a certain tag on each entry(page name?) so that you can recall them easily
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: simple comment box ??

Post by McInfo »

Let's go back to the beginning. Do you have an HTML form with an input for the author's name, a textarea for the comment, and a submit button?

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Wed Jun 16, 2010 12:26 pm, edited 1 time in total.
nits4u
Forum Newbie
Posts: 15
Joined: Tue Jun 23, 2009 3:44 am

Re: simple comment box ??

Post by nits4u »

ya...
"name"= id of author's name
"msg"= id text area
"comment"= form id
Last edited by nits4u on Sat Jun 27, 2009 10:37 am, edited 1 time in total.
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: simple comment box ??

Post by a94060 »

would you be able to post the code to allow us to get an idea of what you would like to do?
nits4u wrote:they shows immediately after posting (like mostly in blogs).
This can be accomplished with AJAX
nits4u
Forum Newbie
Posts: 15
Joined: Tue Jun 23, 2009 3:44 am

Re: simple comment box ??

Post by nits4u »

@ a94060
bro. actually presently its not on my pc.
but i just want a simple comment box on a page(like blogs) and if possible the box also have some basic text editing features.
so that every visitor can post his/her views .
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: simple comment box ??

Post by a94060 »

Alrighty, this can be accomplished by using a form on the page you want to comment on. This can then post to a script to add the comment to a database. You can then use AJAX to call the page again,allowing the new comment to show up.

As for the AJAX code, i dont know :lol: , I am just trying to give you a plan. Hopefully someone more intelligible can write that for you.
nits4u
Forum Newbie
Posts: 15
Joined: Tue Jun 23, 2009 3:44 am

Re: simple comment box ??

Post by nits4u »

lol.. :D
the same prob is with me...
i wrote the code that enter data in Db. but aftr that ???
i dont know.... :banghead:


Vaise thanks...... :)
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: simple comment box ??

Post by McInfo »

Even without AJAX, the comment will appear after the user clicks the submit button.
  1. A client goes to index.php and sees a form.
  2. The client enters data in the form and clicks a submit button, which sends a POST request to index.php.
  3. The server processes the POST data and stores a new record in a database.
  4. The server loads records from the database. The recently added comment is among the retrieved records.
  5. The server formats the comments as HTML and sends this formatted HTML in a reply to the client.
  6. The client sees the list of comments on index.php, including the new comment.
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Wed Jun 16, 2010 12:28 pm, edited 1 time in total.
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: simple comment box ??

Post by a94060 »

ahh,that is true. I forgot that the page does automatically get refreshed after hitting the submit button.
Post Reply