How to create website comment section using Php scripts and MySQL database?

Hi, I'm a newbie to Php and MySQL.

I need a very simple comment section for our website:

All it needs to do is ask for the commenter's email and the comment itself and there would basically be a submit button that does not allow you to continue unless both the commenter's email address box and comment box have been filled up. The comments would have to be saved in a MySOL databse and the comments should appear below the comment box on the webpage.

If possible, can somebody give me the code for that as well? Thanks.

Ennazzusi2013-01-07T06:08:05Z

Favorite Answer

CoffeeCup Web Form Builder is perfect for generating fast and professional online data forms. They offer a free version too.

gonneville2016-12-18T11:46:00Z

Mysql Script Comments

?2013-01-06T10:15:33Z

You would need to know about doing mysql queries.. like INSERT (for inserting comment data) or UPDATE too (depending if you want comments to be edited for example)

You should know about PHP's $_POST and how it works with a form so the form data (i.e the comment data) can be posted and processed.

To not allow a form to be submitted unless it was were filled in you would need to do some php if statements .. e.g..

if($email && $comment == '') {
echo 'Please fill in both fields
}
else {

/// do mysql query here etc

}

You could do form validation with javascript to for better user experience... but highly recommended to validate on server side too incase javascript not enabled on users browser.