User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,198 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,241 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 964 | Replies: 3
Reply
Join Date: Feb 2008
Posts: 2
Reputation: zeplin is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zeplin zeplin is offline Offline
Newbie Poster

Question Comment Box

  #1  
Feb 22nd, 2008
Hi Everyone,

I am very new to web design and just starting to get the basics of CSS and html. Designing is so much fun! My site includes articles and I thought it would be cool to include a comment box. Before coming here I have read many many posts about how to create this.

I am leaning towards using php and setting up a mysql database with my godaddy account. Through the forums I have read, it looks like I have to create two php pages one for adding comments and one for processing comments.

Do I use an html page with reference to the php page (comment box form is in html)?? In other words which page will be used to display the whole page.

How do you control where the comments end up displaying.
ex. above the comment box or below the comment box.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Comment Box

  #2  
Feb 22nd, 2008
If you have any <?php ?> tags in your script, you have to save it with the extension .php . If you want to save it with .html extension, then you need to modify your htaccess file. You can make use of only 1 page/script to do everything.
-- list the comments here --
...
....
Have the fields for name, comments etc, with a submit button. When the form is submitted, get the values and insert it to the table ! A small example.
  1. <?php
  2. if(isset($_POST['submit'])){
  3. $comment=$_POST['comment'];
  4. $q="insert into comments_table (comment) values ('$comment')";
  5. mysql_query($q);
  6. }
  7. $q="select comments from comments_table";
  8. $result=mysql_query($q);
  9. while($row=mysql_fetch_array($result)){
  10. //list the comments
  11. echo $row['comments']."<br />";
  12. }
  13. ?>
  14. <html>
  15. <body>
  16. <form method="Post" action="comments.php">
  17. <textarea name="comments" rows=30 cols=10></textarea>
  18. <input type="submit" name="submit" value="submit">
  19. </form>
  20. </body>
  21. </html>
This is just an example. And comments should be above the 'comment box'..

Cheers,
Naveen
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Feb 2008
Posts: 2
Reputation: zeplin is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zeplin zeplin is offline Offline
Newbie Poster

Re: Comment Box

  #3  
Feb 25th, 2008
Thanks this is helpful. I have not created article pages yet, so the php extension should be no problem. So, if I was creating a new article page and I wanted the guestbook to be on it, how would I add the php pages that I have created for the guestbook?
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Comment Box

  #4  
Feb 25th, 2008
guestbook to be on it ? How do you want to add it ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 10:35 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC