<?php
session_start();
//db
include_once('db.php');
$user_email = $_SESSION['email'];
$resultuid = mysql_query("SELECT `id` FROM `tbluser` WHERE `email` = '$user_email'") or die(mysql_error());
$row_id = mysql_fetch_assoc($resultuid);
$user_id = $row_id['id']; // id of the user
if(isSet($_POST['comment'])){
$gid=$_GET['gid'];
$comment=$_POST['comment'];
$msg_id=$_POST['msg_id'];
$ip=$_SERVER['REMOTE_ADDR'];
$comment=htmlentities($comment);
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$query = mysql_query("SELECT id,comment FROM `group_comments` WHERE uid='$user_id' and msg_id='$msg_id' order by id desc limit 1 ") or die(mysql_error());
$result = mysql_fetch_array($query);
if ($comment!=$result['comment']) {
$query = mysql_query("INSERT INTO `group_comments` (comment, uid, msg_id, created) VALUES ('$comment', '$uid','$msg_id', '$time')") or die(mysql_error());
$newquery = mysql_query("SELECT id, uid, comment, msg_id, created FROM group_comments WHERE uid='$user_id' AND msg_id='$msg_id' order by id desc limit 1 ");
$result = mysql_fetch_array($newquery);
$com_id=$result['id'];
$comment=tolink(htmlentities($result['comment'] ));
$time=$result['created'];
$uid=$result['uid'];
$uinf = mysql_query("SELECT * FROM `tbluser` WHERE `id` = '$uid'") or die(mysql_error());
$row_user = mysql_fetch_array($uinf);
$fullname = $row_user['fname'].' '.$row_user['lname']; // full name of user
$user_photo = $row_user['photo'];
$user_photo="http://nitofa.com/user_pics/users/$user_photo";
header("Location: /groups/?id=".$gid."&msg=Comment posted!#stcommentbody".$com_id);
?>
<div class="stcommentbody" id="stcommentbody<?php echo $com_id; ?>">
<div class="stcommentimg">
<img src="<?php echo $user_photo; ?>" class='small_face'/>
</div>
<div class="stcommenttext">
<!-- <a class="stcommentdelete" href="#" id='<?php echo $com_id; ?>'>X</a> -->
<b><a href="<?php echo 'http://nitofa.com/browse-user.php?fid='.$uid;?>"><?php echo $fullname; ?></a></b> <?php echo $comment; ?>
<div class="stcommenttime"><?php time_stamp($time); ?></div>
</div>
</div>
<?php
}
}
?>
preferences:
35.78 ms | 402 KiB | 5 Q