-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_process.php
More file actions
42 lines (38 loc) · 1.37 KB
/
add_process.php
File metadata and controls
42 lines (38 loc) · 1.37 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
<?php
$link=mysql_connect('localhost','root','111111');
if(!$link) {
die('Could not connect: '.mysql_error());
}
mysql_select_db('opentutorials');
mysql_query("set session character_set_connection=utf8;");
mysql_query("set session character_set_results=utf8;");
mysql_query("set session character_set_client=utf8;");
$title = $_POST['title'];
$description = $_POST['description'];
/*
보안을 위해서는 위의 코드를 아래와 같이 작성해야 합니다.
아래 코드는 이해를 쉽게 하기 위해서 설명을 생략했습니다.
$title = mysql_real_escape_string($_POST['title']);
$description = mysql_real_escape_string($_POST['description']);
*/
$sql = "INSERT INTO topic (title, description, created) VALUES('".$title."', '".$description."', NOW())";
mysql_query($sql);
if(mysql_affected_rows()==1){
echo "
<html>
<head>
<script>
alert('성공 했습니다.');
location.href=\"index.php?id=".mysql_insert_id()."\";
</script>
</head>
</html>";
} else {
echo "
<html>
<body>
실패, ".mysql_error()."
</body>
</html>";
}
?>