RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Comment Box

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: 9
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Comment Box

  #2  
Feb 23rd, 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  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:05 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC