-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendmsg.php
49 lines (47 loc) · 1.31 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
include ("inc/header.inc.php");
if(isset($_GET['u']))
{
$user=mysql_real_escape_string($_GET['u']);
if(ctype_alnum($user))
{
$check=mysql_query("select user_name,user_id from user where user_name='$user'") or die("user_name");
if(mysql_num_rows($check)==1)
{
}
else
{
header("location: $username");
exit();
}
}
}
if($username != $user)
{
if(isset($_POST['sndmsg']))
{
$msgbody=strip_tags($_POST['msgbody']);
if($msgbody=="")
{
echo 'seems like you forgot to write the message.';
}
else
{
$date=date("Y-m-d H:i:s");
$opened="no";
$snd=mysql_query("insert into messages values ('','$username','$user','$msgbody','$date','$opened')");
echo 'Your message has been sent';
header("location: $user");
}
}
if(isset($_POST['cncl']))
{
header("location: $user");
}
echo "<div class='container forms' style='margin:100px'><center><form action='sendmsg.php?u=$user' method='POST'>
<h2>compose a message : ($username) </h2>
<textarea cols='50' rows='10' name='msgbody' placeholder='Enter the text here..'></textarea><br>
<input type='submit' value='Send Message' class='btn btn-primary post' name='sndmsg'>
<input type='submit' value='Cancel' class='btn btn-primary post' name='cncl'>
</form></center></div>";
}