-
Notifications
You must be signed in to change notification settings - Fork 0
/
jschatmsg.php
33 lines (33 loc) · 1.17 KB
/
jschatmsg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
session_start();
date_default_timezone_set(Asia/Kolkata);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING);
include("dbconnection.php");
$dttime = date("Y-m-d h:i:s");
$dt= date("Y-m-d");
$tim = date("h:i:s");
if(isset($_POST[chatsessionid]))
{
$stid = $_POST[chatsessionid];
}
$sqlmessage = "SELECT * FROM chat WHERE (student_id1=$_SESSION[student_id] AND student_id2=$stid) OR (student_id2=$_SESSION[student_id] AND student_id1=$stid) ";
$qsqlmessage = mysqli_query($con,$sqlmessage);
$rsmessage = mysqli_fetch_array($qsqlmessage);
$countmsg =mysqli_num_rows($qsqlmessage);
$msgid=$rsmessage[0];
if($countmsg == 0)
{
$sql = "INSERT INTO chat(chat_id,student_id1,student_id2) VALUES($_SESSION[chatid],$_SESSION[student_id],$stid)";
$qsql = mysqli_query($con,$sql);
echo mysqli_error($con);
$msgid = mysqli_insert_id($con);
}
if($_POST[message] != "")
{
$msg = mysqli_real_escape_string($con,$_POST[message]);
$sql = "INSERT INTO chat_message(chat_id,student_id,date,time,message,message_status) VALUES($msgid,$_SESSION[student_id],$dt,$tim,$msg,Active)";
$qsql = mysqli_query($con,$sql);
echo mysqli_error($con);
}
?>
<!-- <hr class="hr-clas" /> -->