Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Creating a comment form

Featured Replies

On my website www.triumphvillage.com, I have a section where I post my articles. I want readers to write their comments from the form, submit it and see it posted immediately after the article. I want the comments to contain their name, comments and time stamp. Just like a forum. I want these to be in my database as well. Can someone help me?

 

Since I haven't been able to this 'add comment' action, I just allow my readers to submit their comments and send to my email. After that, I will post the comments manually.

 

thanks

Yes - we can help you do that. Please feel free to pm or email me to discuss it further.

 

Kind Regards

 

 

Ed

Use PHP/MyAQL combo. The users' comments would be submitted (using a form) to a database, and show the database contents on the comments page.

  • Author

Hi, thanks for your respond. Actually, I've tried to copy paste the html from a site. I'll show you how I did it below. This is the table comments:

 

CREATE TABLE `comments` (
`commentid` int(11) NOT NULL auto_increment,
`tutorialid` int(11) NOT NULL default '0',
`name` text NOT NULL,
`url` text NOT NULL,
`comment` text NOT NULL,
`email` text NOT NULL,
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`commentid`),
KEY `tutorialid` (`tutorialid`)
)

 

 

This is part of the 'inc_rate.php' file (it's too long to paste everything here):

 

<?
//Please set the following variables for your MySQL database:
//Please set the following variables for your MySQL database:
//it is highly recommended that you restrict access for the user for security reasons
//it only needs "INSERT" privileges

$db_hostname = "localhost"; //usually "localhost be default"
$db_username = ""; //your user name
$db_pass = ""; //the password for your user
$db_name = ""; //the name of the database


/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
--------------------------------------*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);

 

 

This is the 'submitcomment.php':

 

 

<?php
//Please set the following variables for your mysql database:
$db_hostname = "localhost"; //usually "localhost be default"
$db_username = ""; //your user name
$db_pass = ""; //the password for your user
$db_name = ""; //the name of the database


/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
--------------------------------------*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);


$tuturl = $_POST["tuturl"];
$tutid2 = $_POST["tutid2"];
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$message = $_POST["message"];

$sendcomment = mysql_query("INSERT INTO comments SET tutorialid='$tutid2', name='$name', url='$url', email='$email', comment='$message', date=now()");
if($sendcomment){
//header("Location: $tuturl");
echo "<h1>Submission Successful</h1>";
echo "Your comment has been submitted. You will now be redirected back to the last page you visited. Thanks!";
echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";
} else {
echo "There was an error with the submission. ";
}

?>

 

 

So, I've made the table in mysql, made 2 php files, inc_rate.php and submitcomment.php. But, I have a question, I don't know where to put these:

 

 

 

<?php
require('inc_rate.php');
getComments("1");
submitComments("1","$PHP_SELF");
?>

 

 

The tutorial asked me to paste these in my html where I want the comments to be pasted. It doesn't work. For now, if anyone enters the comments and submit the form, I get the data posted onto my database, but it doesn't get pasted anywhere. Please help.

 

Another thing, if I want the comments on separate pages under different articles where the articles are on individual pages, can I have a proper number increment?

 

thanks

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.