-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmsg.php
executable file
·35 lines (34 loc) · 916 Bytes
/
sendmsg.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
<?php
include 'dbconnect.php';
session_start();
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
function noHTML($input, $encoding = 'UTF-8')
{
return htmlentities($input, ENT_QUOTES | ENT_HTML5, $encoding);
}
if($_POST['sendmsg']){
$fromuser_name=$_SESSION['username'];
$touser_name=$_SESSION['touser_name'];
$msg=$_POST['msg'];
$fromuser_name=test_input($fromuser_name);
$touser_name=test_input($touser_name);
$msg=noHTML($msg);
//$msg=mysql_real_escape_string($conn,$msg);
$sql="INSERT INTO kunal_message(touser_name,fromuser_name,msg) VALUES ('$touser_name','$fromuser_name','$msg'); ";
//echo $sql; die();
$result=mysqli_query($conn,$sql);
if($result){
//echo "hie";die();
header("Location:chats.php");
}
else{
}
}
else{
header("Location:home.php");
}