bubblegum Posted April 3, 2006 Share Posted April 3, 2006 I am trying to allow visitors to add comments to my website. It is a very simple site and I rather not learn mysql for just one project. Is there a way using only php to let others post comments?I have a picture on firstpage.html and there is a form below the picture (see below)<form method=post> Name: <br> <INPUT name="name" type="text" size="20"> <p> Comment: <br> <TEXTAREA name="message" rows=3 cols=30 wrap=virtual></TEXTAREA> <p> <input type="submit" name="submit" value="Post"> </form>A visitor would be able to input the name and comment, press "post" and his/her comment would be posted immediately below the picture and so on in reverse chrnological order. The form would move below the most recent comment.Obviously I have the form made but I have no idea what .php file I must make to make this work. My other idea is a link to a separate page where the visitor would input the information and by submitting, it will refer back to firstpage.html and post the comment below the picture. Again, I am not sure how to script that.I would appreciate any help. Thank you. Quote Link to comment Share on other sites More sharing options...
Desdinova Posted April 3, 2006 Share Posted April 3, 2006 well you could write it to a txtfile, but I think you'd still be better of to just learn some mysql. It's quite an easy script you're making, so I'm sure a lot of people out here are willing to help you out with it. for starters:Create a databaseCreate a table with 3 fieldsthe fields are:ID (int, autoincrement, unique)Name (varchar, 80)Comment (text)int, varchar and text are fieldtypes. you'll find them as a dropdownmenu in phpMyAdmin.autoincrement is a dropdown item as well, and unique is found in a checkbox.varchar 80 means there's a max of 80 characters to store in that field. Just put the 80 in the field next to the varchar. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 3, 2006 Share Posted April 3, 2006 I would recommend you to learn just the basics such as INSERT, EDIT and DELETE queries of MySQL as it'll be alot more easier to use a database rather than a flat file database. As with a database you can easily get the infomation you want where as a flat file you will have open it read it the put all the comments into an array sort it then select the correct comment for x picture. A database can do all this with just one query.A database is a hell of alot better. If you want to learn how to use MySQL and PHP then follow through the tutorials [a href=\"http://www.php-mysql-tutorial.com/mysql-tutorial/index.php\" target=\"_blank\"]here[/a] - that is just using MYSQL in a DOS window just to get to grips with mYSQL. Then you'll want to go through tutorial numbers 4 - 7 [a href=\"http://www.php-mysql-tutorial.com/\" target=\"_blank\"]here[/a].Also in order for you to do a comment system I would recommend you to learn how to create a basic guestbook as you can adapt a basic guestbook into a your comment system very easily becuause a questbook is a comment system. [a href=\"http://www.php-mysql-tutorial.com/mysql-php-guestbook.php\" target=\"_blank\"]Part 1[/a] and [a href=\"http://www.php-mysql-tutorial.com/mysql-php-guestbook-2.php\" target=\"_blank\"]Part 2[/a].I know it sounds a lot but learning the basics of MySQL will only take a few hours max. Then a couple more hours to get the basics of PHP and MySQL. Once you've go those under your belt you should be able to be set to create your comment system. Again the guestbook tutorial will tak about 1 - 2 hours if you do that then you'll be able to create your comment system. Quote Link to comment Share on other sites More sharing options...
bubblegum Posted April 3, 2006 Author Share Posted April 3, 2006 Thank you for the replies. I guess I have some reading and studying to do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.