paulmo Posted January 7, 2008 Share Posted January 7, 2008 I'd like to have a reader comments section on website like blogger does:link I only know some html and css, using notepad for about 2 weeks now. my site is at Visit My WebsiteI heard user comments are done in php. Where to begin? Any copy/paste/edit solutions? Link to comment Share on other sites More sharing options...
real_illusions Posted January 7, 2008 Share Posted January 7, 2008 Theres a few ways to go about this. 2 most common is probably - 1 - user fills out a form, you get an email, and you update the website with the comments. This does filter out all spam, but yet is slow, as the user comments dont appear straight away2 - user fills out form, it goes into a database (of some kind, either mysql or an xml file), and then you echo the database entries onto the page. Only real way of preventing spam is by using a captcha on your form. You can always delete entries via myphpadmin (or phpmyadmin, i forget which round it is) from the database if you feel comment isn't suitableSince you dont know php, #1 is easy..however, it involves alot of work. Especially if you get millions of comments.Else you can search for 'guestbooks' or something in google, and you'll get a few million results.hope that helps:) Link to comment Share on other sites More sharing options...
paulmo Posted January 7, 2008 Author Share Posted January 7, 2008 1 - user fills out a form, you get an email, and you update the website with the comments.Already figured this one out.2 - user fills out form, it goes into a database (of some kind, either mysql or an xml file), and then you echo the database entries onto the page. Only real way of preventing spam is by using a captcha on your form. You can always delete entries via myphpadmin (or phpmyadmin, i forget which round it is) from the database if you feel comment isn't suitablethis is what i need...while you were responding i was setting up mysql database in my host/server account. figured even though i know nothing it's a start...yes there is a phpmyadmin section...there's export/import, query window. so from here, guessing i need php code for user comments in my index.htm file then ftp to host/server? does mysql database read php code in the index.htm file? or is there more to it? suggestions for comments section code? thanks illusions and whoever else-- Link to comment Share on other sites More sharing options...
real_illusions Posted January 8, 2008 Share Posted January 8, 2008 What you need is for when a user fills out a form, it then needs to 'talk' to the database. The database is just that, a base where data is stored. Nothing else. You need a language like sql and php to talk to that database and do something useful with it.In this case, when the user fills out the form and presses submit, the information that the user put in, is sent to the database and stored in there.Email goes into email row, username goes into username row, comments into comments row etc etc..You then create a script on another page where the guestbook is, where it reads whats in the database and outputs it to the browser.I dont know how to do this, but i could probably research how to and build a very basic one.Whichever way you go, you have to be aware of security. Such as spam, sql injections etc.. Link to comment Share on other sites More sharing options...
paulmo Posted January 8, 2008 Author Share Posted January 8, 2008 thanks for explaining that process. are scripts a good way to go? i'm seeing a lot of comments/guestbook googling php scripts. Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted January 8, 2008 Share Posted January 8, 2008 I making one, not very far, but I am hopping to get it up in... I don't really know when! I'll let you know when its done if you want so you can use it... Link to comment Share on other sites More sharing options...
morrisjohnny Posted January 10, 2008 Share Posted January 10, 2008 I have a "simple" guestbook at home. I should be home in around 6 hours if you are interested in my giving it to you message me so i have a reminder when i go home :-)I will be adding more features to it over the next few days so i'll keep you posted but theirs a basic working one tht's easy to implment Link to comment Share on other sites More sharing options...
morrisjohnny Posted January 10, 2008 Share Posted January 10, 2008 Heres my very simple php comment bookclick on phpmyadmin and click on your database and click import and copy and paste into the text area you have and click okay. <?php//config$sql_host="localhost"; // Your sql host (often localhost)$sql_username="root"; // Your sql username$sql_password=""; // Your sql password$sql_database="projects"; // Youd database name$sql_table="guest_book"; // Your table$list="1"; // 1 = Above forum, 2 = Below forum//End of Config Change Nothing Below this line unless you know what you are doing$con = mysql_connect($sql_host,$sql_username,$sql_password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($sql_database, $con);if (isset($_POST['Name'])) { $name=mysql_real_escape_string($_POST['Name']); $message=mysql_real_escape_string($_POST['Comment']); $sql="INSERT INTO $sql_table (Name, Message) VALUES ('$name','$message')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else { if ($list=="1") { $result = mysql_query("SELECT * FROM $sql_table ORDER BY ID"); while($row = mysql_fetch_array($result)) { echo "<strong>".$row['Name']."</strong><br /><i>".$row['Message']."</i><br /><hr /><br />"; } mysql_close($con); } echo" <form name=\"input\" action=\"\"method=\"post\"> <input type=\"text\" value=\"Name\" name=\"Name\" value=\"Name\" /><br /> <input type=\"text\" name=\"Comment\" value=\"Comment\" /><br /> <input type=\"Submit\" Value=\"Submit\" /><input type=\"Reset\" Value=\"Reset\" /><br /> </form> "; if ($list=="2") { $result = mysql_query("SELECT * FROM $sql_table ORDER BY ID"); while($row = mysql_fetch_array($result)) { echo "<strong>".$row['Name']."</strong><br /><i>".$row['Message']."</i><br /><hr /><br />"; } mysql_close($con); } } }else { if ($list=="1") { $result = mysql_query("SELECT * FROM $sql_table ORDER BY ID"); while($row = mysql_fetch_array($result)) { echo "<strong>".$row['Name']."</strong><br /><i>".$row['Message']."</i><br /><hr /><br />"; } mysql_close($con); }echo" <form name=\"input\" action=\"\"method=\"post\"> <input type=\"text\" value=\"Name\" name=\"Name\" /><br /> <input type=\"text\" name=\"Comment\" value=\"Comment\" /><br /> <input type=\"Submit\" Value=\"Submit\" /><input type=\"Reset\" Value=\"Reset\" /><br /> </form> "; if ($list=="2") { $result = mysql_query("SELECT * FROM $sql_table ORDER BY ID"); while($row = mysql_fetch_array($result)) {if ($links=="1") { echo"<a href=\"".$row['Link']."\">".$row['Name']."</a>"; } else { echo $row['Name']; } echo "<br />".$row['Message']."<br /><hr /><br />"; } mysql_close($con); } }?> Link to comment Share on other sites More sharing options...
coolgamer48 Posted January 13, 2008 Share Posted January 13, 2008 I just finished a comment/guestbook thing for my site (alecbenzer.com).You COULD go out and look for a script to do it for you, or you could learn php w3schools.com/php and make one yourself - and then feel all special inside! :)Also, instead of deleting comments - I'd have a field in your database called display, and set it to yes if it should be displayed (default), or no for stuff like spam or test comments you post. But that probably doesn't help you right now... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.