-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathu_addLiveChat.php
44 lines (30 loc) · 894 Bytes
/
u_addLiveChat.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
34
35
36
37
38
39
40
41
42
43
44
<?php
$host = "127.0.0.1";
$user = "root";
$password = "";
$db="login_it";
session_start();
if(!isset($_SESSION["username"])){
header("location:login.php");
}
if(empty($_POST["body"])){
die("Body required");
}
$mysqli = require __DIR__ . "/database.php";
$data=mysqli_connect($host,$user,$password,$db);
$to_user= $_GET["employeeid"];
//get the current time and date
$time=date("Y-m-d h:s:m");
//insert a live chat dataset into database
$sql= "INSERT INTO livechats (to_user, from_user, time, body, subject) VALUES (?,?,?,?,?)";
$stmt = $mysqli->stmt_init();
if(!$stmt -> prepare($sql)){
die("SQL error: .$mysqli->error");
}
$stmt->bind_param("sssss", $to_user, $_SESSION["username"], $time, $_POST["body"], $_POST["subject"]);
//when finished go back to livechat page
if($stmt->execute()){
header("Location: u_livechat.php?employeeid=".$to_user);
exit;
}
?>