-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
32 lines (27 loc) · 710 Bytes
/
Copy pathsend.php
File metadata and controls
32 lines (27 loc) · 710 Bytes
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
//retreive values from cookie
$them = $_COOKIE['chat_them'];
$you = $_COOKIE['chat_you'];
if (isset($_POST['message'])
&& !empty($_POST['message']))
{
if (mysql_connect("hostname","user","password"))
{
if (mysql_select_db("db"))
{
//sanitize input
$message = mysql_real_escape_string($_POST['message']);
if (mysql_query("INSERT INTO `messages` (`sender`,`message`,`timestamp`,`read`,`recipient`) VALUES ('{$you}','{$message}',NOW(),0,'{$them}')"))
echo "sent";
else
echo "INSERT error";
}
else
echo "Database error";
}
else
echo "Connection error";
}
else
echo "POST empty";
?>