Here's some code to help you
theme.php
// HTML template for the display of comments
$template_image_comments = <<<EOT
<table align="center" width="650" cellspacing="0" cellpadding="0" class="maintable">
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="tableh2_compact" style="white-space: nowrap;">
<b>{MSG_AUTHOR}</b>
<!-- BEGIN ipinfo -->
({HDR_IP} [{RAW_IP}])
<!-- END ipinfo -->
</td>
<td class="tableh2_compact" align="right" width="100%">
<!-- BEGIN buttons -->
<a href="javascript:;" onclick="blocking('cbody{MSG_ID}','', 'block'); blocking('cedit{MSG_ID}','', 'block'); return false;" title="{EDIT_TITLE}"><img src="images/edit.gif" border="0" align="middle"/></a>
<a href="delete.php?msg_id={MSG_ID}&what=comment" onclick="return confirm('{CONFIRM_DELETE}');"><img src="images/delete.gif" border="0" align="middle" /></a>
<!-- END buttons -->
</td>
<td class="tableh2_compact" align="right" style="white-space: nowrap;">
<span class="comment_date">[{MSG_DATE}]</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="tableb_compact">
<div id="cbody{MSG_ID}" style="display:block">
{MSG_BODY}
</div>
<div id="cedit{MSG_ID}" style="display:none">
<!-- BEGIN edit_box_smilies -->
<table width="100%" cellpadding="0" cellspacing="0">
<form name="f{MSG_ID}" method="POST" action="db_input.php">
<input type="hidden" name="event" value="comment_update" />
<input type="hidden" name="msg_id" value="{MSG_ID}" />
<tr>
<td>
<input type=text name=msg_author value="{MSG_AUTHOR}" class="textinput" size="10" />
</td>
</tr>
<tr>
<td width="80%">
<textarea cols="40" rows="2" class="textinput" name="msg_body" onselect="storeCaret_f{MSG_ID}(this);" onclick="storeCaret_f{MSG_ID}(this);" onkeyup="storeCaret_f{MSG_ID}(this);" style="width: 100%;">{MSG_BODY_RAW}</textarea>
</td>
<td class="tableb_compact">
</td>
<td>
<input type="submit" class="comment_button" name="submit" value="{OK}" />
</td>
</form>
</tr>
<tr>
<td colspan="3"><img src="images/spacer.gif" width="1" height="2" alt=""/><br /></td>
</tr>
</table>
{SMILIES}
<!-- END edit_box_smilies -->
<!-- BEGIN edit_box_no_smilies -->
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<form name="f{MSG_ID}" method="POST" action="db_input.php">
<input type="hidden" name="event" value="comment_update" />
<input type="hidden" name="msg_id" value="{MSG_ID}" />
<td>
<input type=text name=msg_author value="{MSG_AUTHOR}" class="textinput" size="10" />
</td>
</tr>
<tr>
<td width="100%">
<textarea cols="40" rows="2" class="textinput" name="msg_body" style="width: 100%;">{MSG_BODY_RAW}</textarea>
</td>
<td class="tableb_compact">
</td>
<td>
<input type="submit" class="comment_button" name="submit" value="{OK}" />
</td>
</form>
</tr>
<tr>
<td colspan="3"><img src="images/spacer.gif" width="1" height="2" alt=""/><br /></td>
</tr>
</table>
<!-- END edit_box_no_smilies -->
</div>
</td>
</tr>
</table>
EOT;
$template_add_your_comment = <<<EOT
<form method="post" name="post" action="db_input.php">
<table align="center" width="650" cellspacing="0" cellpadding="0" class="maintable">
<tr>
<td class="tableh2_compact"><b>{ADD_YOUR_COMMENT}</b>
</td>
</tr>
<tr>
<td colspan="3">
<input type="hidden" name="event" value="comment" />
<input type="hidden" name="pid" value="{PIC_ID}" />
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<!-- BEGIN user_name_input -->
<td class="tableb_compact">
{NAME}
</td>
<td class="tableb_compact">
<input type="text" class="textinput" name="msg_author" size="10" maxlength="20" value={USER_NAME} />
</td>
<!-- END user_name_input -->
<!-- BEGIN input_box_smilies -->
<td class="tableb_compact">
{COMMENT} </td>
<td width="100%" class="tableb_compact">
<input type="text" class="textinput" id="message" name="msg_body" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" maxlength="{MAX_COM_LENGTH}" style="width: 100%;" /> <!-- END input_box_smilies -->
<!-- BEGIN input_box_no_smilies -->
<input type="text" class="textinput" id="message" name="msg_body" maxlength="{MAX_COM_LENGTH}" style="width: 100%;" />
<!-- END input_box_no_smilies -->
</td>
<td class="tableb_compact">
<input type="submit" class="comment_button" name="submit" value="{OK}" />
</td>
</tr>
</table>
</td>
</tr>
<!-- BEGIN smilies -->
<tr>
<td width="100%" class="tableb_compact">
{SMILIES}
</td>
</tr>
<!-- END smilies -->
</table>
</form>
EOT;
dbinput.php
// Comment
case 'comment':
if (!(USER_CAN_POST_COMMENTS)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
check_comment($HTTP_POST_VARS['msg_body']);
$msg_author = addslashes(trim($HTTP_POST_VARS['msg_author']));
$msg_body = addslashes(trim($HTTP_POST_VARS['msg_body']));
$pid = (int)$HTTP_POST_VARS['pid'];
if ($msg_author == '' || $msg_body == '') cpg_die(ERROR, $lang_db_input_php['empty_name_or_com'], __FILE__, __LINE__);
$result = db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'");
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
$album_data = mysql_fetch_array($result);
mysql_free_result($result);
if ($album_data['comments'] != 'YES') cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
if (!$CONFIG['disable_comment_flood_protect']){
$result = db_query("SELECT author_md5_id, author_id FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid = '$pid' ORDER BY msg_id DESC LIMIT 1");
if (mysql_num_rows($result)) {
$last_com_data = mysql_fetch_array($result);
if ((USER_ID && $last_com_data['author_id'] == USER_ID) || (!USER_ID && $last_com_data['author_md5_id'] == $USER['ID'])) {
cpg_die(ERROR, $lang_db_input_php['no_flood'], __FILE__, __LINE__);
}
}
}
if (!USER_ID) { // Anonymous users, we need to use META refresh to save the cookie
$insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
$USER['name'] = $HTTP_POST_VARS['msg_author'];
$redirect = "displayimage.php?pos=" . (- $pid);
if ($CONFIG['email_comment_notification']) {
$mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body'] . " " . $CONFIG['ecards_more_pic_target'] . $redirect;
cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
}
pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
pagefooter();
ob_end_flush();
exit;
} else { // Registered users, we can use Location to redirect
$insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '" . addslashes(USER_NAME) . "', '$msg_body', NOW(), '', '" . USER_ID . "', '$raw_ip', '$hdr_ip')");
$redirect = "displayimage.php?pos=" . (- $pid);
if ($CONFIG['email_comment_notification']) {
$mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body'] . " " . $CONFIG['ecards_more_pic_target'] . $redirect;
cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
}
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
header($header_location . $redirect);
pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
pagefooter();
ob_end_flush();
exit;
}
break;
i hope this help