-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsgroupchatmsg.php
32 lines (28 loc) · 1.04 KB
/
jsgroupchatmsg.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
<?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");
$sqlmessage = "SELECT * FROM group_chat WHERE course_id=$_POST[coursetitle] AND semester=$_POST[semester] ";
$qsqlmessage = mysqli_query($con,$sqlmessage);
$rsmessage = mysqli_fetch_array($qsqlmessage);
$countmsg =mysqli_num_rows($qsqlmessage);
$msgid=$rsmessage[0];
if($countmsg == 0)
{
$sql = "INSERT INTO group_chat(course_id,semester) VALUES($_POST[coursetitle],$_POST[semester])";
$qsql = mysqli_query($con,$sql);
echo mysqli_error($con);
$msgid = mysqli_insert_id($con);
}
if($_POST[textmsg] != "")
{
$msg = mysqli_real_escape_string($con,$_POST[textmsg]);
$sql = "INSERT INTO chat_message(group_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" /> -->