<?php include("../db_connection.php");
//echo'<pre>';print_r($_POST);exit;


$ad=mysql_query("select * from tbl_ads where ads_id='".$_POST['adid']."'");
$re=mysql_fetch_assoc($ad);



if(isset($_POST['sender']) && $_POST['sender']!=="")
{
	
	$receiver=$_POST['sender'];
}
else
{
	$receiver=$re['posted_userid'];
}


$sql=mysql_query("insert into tbl_chats (ads_id,msg,sender_id,receiver_id,datetime)values('".$_POST['adid']."','".$_POST['msg']."','".$_SESSION['cid']."','".$receiver."',now())");


$sender=mysql_query("select * from tbl_users where userid='".$_SESSION['cid']."'");
$ressender=mysql_fetch_assoc($sender);

?>
<div class="row msg_container base_sent">
        <div class="col-md-9 col-xs-9">
            <div class="messages msg_sent">
                <p><?php echo $_POST['msg'];?></p>
                <time datetime="2009-11-13T20:00"><?php echo date('d M Y h:i:sa');?></time>
            </div>
        </div>
        <div class="col-md-3 col-xs-3 avatar">
            <strong><?php echo ucfirst($ressender['fullname']);?></strong>
            <!--<img src="<?php ?>" class=" img-responsive ">-->
        </div>
    </div>
<?php
?>