-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage_insert.php
51 lines (43 loc) ยท 1.19 KB
/
message_insert.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
50
51
<meta charset='utf-8'>
<?php
$send_id = $_GET["send_id"];
$rv_id = $_POST['rv_id'];
$subject = $_POST['subject'];
$content = $_POST['content'];
$subject = htmlspecialchars($subject, ENT_QUOTES);
$content = htmlspecialchars($content, ENT_QUOTES);
$regist_day = date("Y-m-d (H:i)"); // ํ์ฌ์ '๋
-์-์ผ-์-๋ถ'์ ์ ์ฅ
if(!$send_id) {
echo("
<script>
alert('๋ก๊ทธ์ธ ํ ์ด์ฉํด ์ฃผ์ธ์! ');
history.go(-1)
</script>
");
exit;
}
$con = mysqli_connect("localhost", "user1", "12345", "sample");
$sql = "select * from members where id='$rv_id'";
$result = mysqli_query($con, $sql);
$num_record = mysqli_num_rows($result);
if($num_record)
{
$sql = "insert into message (send_id, rv_id, subject, content, regist_day) ";
$sql .= "values('$send_id', '$rv_id', '$subject', '$content', '$regist_day')";
mysqli_query($con, $sql); // $sql ์ ์ ์ฅ๋ ๋ช
๋ น ์คํ
} else {
echo("
<script>
alert('์์ ์์ด๋๊ฐ ์๋ชป ๋์์ต๋๋ค!');
history.go(-1)
</script>
");
exit;
}
mysqli_close($con); // DB ์ฐ๊ฒฐ ๋๊ธฐ
echo "
<script>
location.href = 'message_box.php?mode=send';
</script>
";
?>