LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-07-2009, 01:06 AM   #1
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Rep: Reputation: 30
How do I make user comments display?


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.

Code:
<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 displayed?

Last edited by SentralOrigin; 01-07-2009 at 01:08 AM.
 
Old 01-07-2009, 01:57 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Have a look at PHP, you need some server side scripting to process the data from the form.

I would suggest storing the data in an XML file
 
Old 01-07-2009, 02:04 AM   #3
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Disillusionist View Post
Have a look at PHP, you need some server side scripting to process the data from the form.

I would suggest storing the data in an XML file
How long would it take me to learn PHP for this?
 
Old 01-07-2009, 02:22 AM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
PHP is quite an easy language to get to grips with, and there are online tutorials which should help.

Here is a link to the PHP section of w3schools: http://w3schools.com/php/default.asp

And here is one from PHP.net: http://uk2.php.net/tut.php
 
Old 01-07-2009, 02:54 AM   #5
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
I don't understand any of this stuff. How do I make it grab the comment, put it into a file, then read the file again and post the comment where I want it to on the page?
 
Old 01-07-2009, 05:43 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,361

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Maybe its not clear to you that HTML = Hypertext Markup Language. Its a page layout lang, not a programming language. IOW you need a prog lang (ie to implement CGI - Computer Gateway Interface ability).
You need a lang that is Turing complete ie can actually manipulate/implement stuff like vars, loops, decisions, files etc. HTML is NOT that lang.
Use PHP (as suggested) or Perl etc.

Apologies if you do already understand this.

PHP: http://www.php.net/docs.php
Perl: http://perldoc.perl.org/ , http://www.perlmonks.org/?node=Tutorials
 
Old 01-07-2009, 06:09 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, SentralOrigin -

It sounds like what you're looking for is a "Bulletin Board" program. One good alternative is phpBB:

http://www.phpbb.com/

Here are a couple of other choices:

http://www.opensourcescripts.com/dir...s_,038_Forums/

All of these require the following:

1. A web server (for example, Apache)
<= your bulletin board program is basically a "web application" run off of your web server.

2. A database (for example, mySQL)
<= a database is usually better than a text file to hold comments ... and, for that matter, to store usernames and other stuff related to your bulletin board.

3. A scripting language (for example, Perl, PHP or ASP.Net)
<= The scripting language can read and write to the database and dynamically generate the HTML the user sees in his browser.
The script is the "glue" that makes a web application possible.

'Hope that helps .. PSM

Last edited by paulsm4; 01-07-2009 at 06:12 PM.
 
Old 01-08-2009, 01:26 AM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Hi SentralOrigin,

Please let us know if you are running your own web server, or are you using a hosted service.

If you are running your own web server, then you will be less restricted in what you can run (although you will need to install and configure the server yourself).

If you are using a hosted service, you may find that PHP is already installed and configured, although a lot of hosted services do not allow for running a database on their cheapest band.

If this is a hosted service, create a file called info.php
Code:
<?php phpinfo(); ?>
Then browse to that page. If PHP is installed you wil be given an information page.
 
Old 01-08-2009, 08:41 AM   #9
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
I am running my own web server.

I created info.php in my /var/www/ directory with my index.html and other pages, and put in
Code:
<?php phpinfo(); ?>
then went to http://myip/info.php and it displayed a bunch of information about PHP5 or something
 
Old 01-08-2009, 09:45 AM   #10
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by paulsm4 View Post
Hi, SentralOrigin -

It sounds like what you're looking for is a "Bulletin Board" program.
...
Okay, I guess I might have confused some people about what I needed. I'm going to use an example from Slashdot:


I post website news on my homepage:


http://i40.tinypic.com/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:


http://i44.tinypic.com/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):


http://i44.tinypic.com/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).
 
Old 01-08-2009, 10:16 AM   #11
rsciw
Member
 
Registered: Jan 2009
Location: Essex (UK)
Distribution: Home: Debian/Ubuntu, Work: Ubuntu
Posts: 206

Rep: Reputation: 44
you'll definitely need a database and php for that (or perl, not familiar with it though...)
as someone mentioned already, php isn't that difficult to learn.
but with input forms etc you will also need to look into 'SQL injections'.

a database table design for that shouldn't be too complex I reckon
ID -- title -- text -- date_entered -- linked_article_id

that should be it.

comments entered into your form will be processed via php and entered into the db,
and from there it can be accessed again via php to display the comments to specific articles order by date
on a given page.
 
Old 01-08-2009, 05:24 PM   #12
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
I checked this out: http://www.gentlesource.com/comment-script/

But I wasn't sure which snippets of code I needed to copy out to make the information from the form on my website page be put into a MySQL database I just created.
 
Old 01-08-2009, 05:34 PM   #13
rsciw
Member
 
Registered: Jan 2009
Location: Essex (UK)
Distribution: Home: Debian/Ubuntu, Work: Ubuntu
Posts: 206

Rep: Reputation: 44
not sure.
will maybe have a look at it tomorrow, when I'm not half asleep

but wondering though, why not take one of the many free available (under the GPL) tools instead of one where you have to prominently show up where it comes from, or buy a licence for it?

here's the installation guide from the accompanying PDF:

1. Connect to your web server using an FTP program.
2. Create a new folder on your server named i.e. comments.
3. Upload the whole script including all files and folders to your server into the new
folder. Make sure the original file structure appears on the server. Read more details
in chapter 4.2 Upload.
4. Make sure the script folder and the sub-folder cache are writable by the script
(chmod 777). Read more details in the chapter 4.3 File and Folder Permissions. If
those folders are not writable the installation will fail.
5. Call the admin area of the script in your browser:
http://www.example.com/comments/admin/
6. You are probably seeing now the installation screen of the script. Please make sure
you have the database access data. Read more details in chapter 4.4 Database
Access Data.
7. Choose a prefix for the database tables. Default value is c5t_ and there is actually
no need to change that unless you want to have more than one installation of the
script side by side.
8. Enter the information for the admin account you want to create and use, once the
script is working.
9. Click the button Install Now. In case the installation was successful, you will be
provided with a link to the login screen where you can use the account data you just
entered.


should be relatively easy to do

Last edited by rsciw; 01-08-2009 at 05:37 PM.
 
Old 01-08-2009, 06:26 PM   #14
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
I did all of that, and it worked fine, except when I load it, it goes to a separate comment page, and I don't like the way it displays on separate pages. I want it to display on my own page that I already made, along with the article above it
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Just loaded Mepis 6.0 - French user - make new user - speed of machine NewbiePenguinista MEPIS 3 01-04-2007 04:03 PM
Using egrep to display C++ code without comments ckoniecny Linux - General 2 11-07-2006 11:49 PM
New User Intro + Questions/Comments TerryP Slackware - Installation 7 05-10-2006 10:05 PM
what is the command to make a user change their password after creating a new user? naweenio Linux - Newbie 7 01-05-2005 07:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration