-
Notifications
You must be signed in to change notification settings - Fork 0
/
mento_insert.php
145 lines (127 loc) Β· 6.11 KB
/
mento_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<meta charset="utf-8">
<?php
$university = $_GET["university"];
session_start();
if (isset($_SESSION["userid"])) $userid = $_SESSION["userid"];
else $userid = "";
if (isset($_SESSION["username"])) $username = $_SESSION["username"];
else $username = "";
if ( !$userid )
{
echo("
<script>
alert('κ²μν κΈμ°κΈ°λ λ‘κ·ΈμΈ ν μ΄μ©ν΄ μ£ΌμΈμ!');
history.go(-1)
</script>
");
exit;
}
$subject = $_POST["subject"];
$content = $_POST["content"];
$subject = htmlspecialchars($subject, ENT_QUOTES);
$content = htmlspecialchars($content, ENT_QUOTES);
$regist_day = date("Y-m-d (H:i)"); // νμ¬μ 'λ
-μ-μΌ-μ-λΆ'μ μ μ₯
$upload_dir = './data/';
$upfile_name = $_FILES["upfile"]["name"];
$upfile_tmp_name = $_FILES["upfile"]["tmp_name"];
$upfile_type = $_FILES["upfile"]["type"];
$upfile_size = $_FILES["upfile"]["size"];
$upfile_error = $_FILES["upfile"]["error"];
if ($upfile_name && !$upfile_error)
{
$file = explode(".", $upfile_name);
$file_name = $file[0];
$file_ext = $file[1];
$new_file_name = date("Y_m_d_H_i_s");
$new_file_name = $new_file_name;
$copied_file_name = $new_file_name.".".$file_ext;
$uploaded_file = $upload_dir.$copied_file_name;
if( $upfile_size > 1000000 ) {
echo("
<script>
alert('μ
λ‘λ νμΌ ν¬κΈ°κ° μ§μ λ μ©λ(1MB)μ μ΄κ³Όν©λλ€!<br>νμΌ ν¬κΈ°λ₯Ό 체ν¬ν΄μ£ΌμΈμ! ');
history.go(-1)
</script>
");
exit;
}
if (!move_uploaded_file($upfile_tmp_name, $uploaded_file) )
{
echo("
<script>
alert('νμΌμ μ§μ ν λλ ν 리μ 볡μ¬νλλ° μ€ν¨νμ΅λλ€.');
history.go(-1)
</script>
");
exit;
}
}
else
{
$upfile_name = "";
$upfile_type = "";
$copied_file_name = "";
}
$con = mysqli_connect("localhost", "user1", "12345", "sample");
if($university=="건μλνκ΅")
$sql = "insert into mentofind (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="λμ λνκ΅")
$sql = "insert into mentofind1 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="λμ μ νλνκ΅")
$sql = "insert into mentofind2 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="λͺ©μλνκ΅")
$sql = "insert into mentofind3 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="λ°°μ¬λνκ΅")
$sql = "insert into mentofind4 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="μ°μ‘λνκ΅")
$sql = "insert into mentofind5 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="μμ§λνκ΅")
$sql = "insert into mentofind6 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="μΆ©λ¨λνκ΅")
$sql = "insert into mentofind7 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="μΉ¨λ‘μ νλνκ΅")
$sql = "insert into mentofind8 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="νκ΅κ³ΌνκΈ°μ μ")
$sql = "insert into mentofind9 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="νλ¨λνκ΅")
$sql = "insert into mentofind10 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="νλ°λνκ΅")
$sql = "insert into mentofind11 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="λλλνκ΅")
$sql = "insert into mentofind12 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="λμ 보건λνκ΅")
$sql = "insert into mentofind13 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="μ°μ‘μ 보λνκ΅")
$sql = "insert into mentofind14 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="λμ κ³ΌνκΈ°μ νκ΅")
$sql = "insert into mentofind15 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="νκ΅ν΄λ¦¬ν
IVλνκ΅")
$sql = "insert into mentofind16 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="κ³ΌνκΈ°μ μ°ν©λνμλνκ΅")
$sql = "insert into mentofind17 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="건μ λνμλνκ΅")
$sql = "insert into mentofind18 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="건μμ¬μ΄λ²λνκ΅")
$sql = "insert into mentofind19 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="νκ΅λ°©μ‘ν΅μ λνκ΅")
$sql = "insert into mentofin20 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
elseif($university=="none")
$sql = "insert into mentofind21 (id, name, subject, content, regist_day, hit, file_name, file_type, file_copied) ";
$sql .= "values('$userid', '$username', '$subject', '$content', '$regist_day', 0, ";
$sql .= "'$upfile_name', '$upfile_type', '$copied_file_name')";
mysqli_query($con, $sql); // $sql μ μ μ₯λ λͺ
λ Ή μ€ν
// ν¬μΈνΈ λΆμ¬νκΈ°
$point_up = 100;
$sql = "select point from members where id='$userid'";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
$new_point = $row["point"] + $point_up;
$sql = "update members set point=$new_point where id='$userid'";
mysqli_query($con, $sql);
mysqli_close($con); // DB μ°κ²° λκΈ°
echo "
<script>
location.href = 'mento_find_list.php?university=$university';
</script>
";
?>