Jump to content

How do I make user comments display?


guitarscn

Recommended Posts

I got as far as displaying a text input box where a user can type in a name and a message (okay, I just stole it from another site, but it seems to work fine). I need the username, the comment they post, and the date it was posted to appear on the same page as the comment box. (The comment box is above the comment area, so when a user submits a comment, it will appear right below it, along with other comments users will submit, separated by a line or something.

 

<div class="opt-spe">
<div class="rt">Comments</div>
Add a new comment: </div>
<form name="new_comment" method="post">
<input type="hidden" name="res" value="7029c8f06ef7e12a7d186cfafe2bbd1c" />
<div class="cmtadd"><table cellspacing="0" cellpadding="0" class="cmtadd">
<tr><td>Username: (required)</td><td><input type="text" name="user" maxlength="20" /></td></tr>
<tr><td>Text: (required)</td><td><textarea name="text"></textarea></td></tr>
<tr><td colspan="2" style="text-align: center;"><input type="submit" class="ibut" value="Submit comment" /> <input type="reset" class="ibut" value="Clear" /></td></tr>
</div>
</table>

 

What do I have to do now? How can I make the submitted comments be saved in a separate file (it doesn't have to be, but I'm assuming that's how it works), and then displayed where I want it to?

Link to comment
https://forums.phpfreaks.com/topic/139821-how-do-i-make-user-comments-display/
Share on other sites

Okay, I might have confused some people about what I needed so I'll try to make it clearer. I'm going to use an example from Slashdot:

 

 

I post website news on my homepage:

 

 

zj9lqh.jpg

 

 

 

 

 

When a user clicks on 'Comments,' it leads to another page that looks just like the homepage, except it only displays that one news article that the person clicked on 'Comments' for:

 

 

2prttaq.jpg

 

 

 

 

 

The format I want for the Comments section below the article is "Posted by [insert user here] on [insert date here]" followed by a break, the person's message, then a break, then a line to separate the comment from the next comment that will be displayed below that.

 

The Comment input part between the article and the comments would look like this (just not as ugly):

 

 

qs77s3.jpg

 

 

Which is the only thing I already have (the input boxes and Submit button I already have done, but the Submit button doesn't do anything).

You have a mysql database set up?

What fields did you create in the database?

 

All you need to do is insert into your database the $_POST variables of your form, THEN

echo the information that was just put into your database, onto the page where you want

them

You have a mysql database set up?

What fields did you create in the database?

 

All you need to do is insert into your database the $_POST variables of your form, THEN

echo the information that was just put into your database, onto the page where you want

them

 

The database is empty because I'm not really sure what to do with it. What are $_POST variables? My form is written in HTML

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.