-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
43 lines (30 loc) · 1.13 KB
/
Copy pathsend.php
File metadata and controls
43 lines (30 loc) · 1.13 KB
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
<?php
session_start();
if(ISSET($_SESSION['user']))
{
$dbcon = new mysqli('localhost', 'S0267455', 'New2016', 'S0267455');
$sender = $dbcon->real_escape_string($_SESSION['user']);
$subject = $dbcon->real_escape_string($_POST['subject']);
$text = $dbcon->real_escape_string($_POST['message']);
$sendtos = array();
foreach($_POST['people'] as $value)
$sendtos[] = $value;
$result = $dbcon->query("SELECT u_userid FROM Users WHERE u_username='$sender'");
$user_obj = $result->fetch_object();
$dbcon->query("INSERT INTO Messages (m_fromid, m_sent, m_subject, m_text)
VALUES ('$user_obj->u_userid', NOW(), '$subject', '$text')");
$last_id = $dbcon->insert_id;
foreach($sendtos as $target)
{
$targetx = $dbcon->real_escape_string($target);
$temp = $dbcon->query("SELECT u_userid FROM Users WHERE u_username='$targetx'");
$temp_obj = $temp->fetch_object();
$targetid = $temp_obj->u_userid;
$dbcon->query("INSERT INTO SendTos (s_msgid, s_toid)
VALUES ('$last_id', '$targetid')");
}
echo "Message sent!<br>
Go <a href=\"login.php\">Home</a><br>
<a href=\"newmessage.php\">New Message</a>";
}
?>