-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwrite_form.php
34 lines (30 loc) · 942 Bytes
/
write_form.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<?php
date_default_timezone_set('Asia/Seoul');
$db = new PDO("mysql:dbname=qna;host:localhost", "lsm", "333");
$rows = $db->query("SELECT * from board order by post_number desc;");
$id = $_POST['name'];
$title = $_POST['title'];
$content = $_POST['content'];
$date = date('Y-m-d');
$URL = './qna.php';
$query = "INSERT into board (title, content, id, date, views) values('$title', '$content','$id', '$date',0)";
$result = $db->exec($query);
if ($result) { ?>
<script>
alert("<?= "글쓰기가 완료되었습니다." ?>");
location.replace("<?php echo $URL ?>");
</script>
<?php } else {
echo "FAIL";
} ?>
</body>
</html>