-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
56 lines (52 loc) · 1.38 KB
/
edit.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>수정</title>
<?php
$wrong_connection = <<< HERE
<script>
alert('잘못된 접근입니다.');
location.replace('/');
</script>
HERE;
if(!isset($_SESSION['user_id']))
{
echo $wrong_connection;
}
if($_SERVER['REQUEST_METHOD'] == "GET")
{
$post_num = $_GET['number'];
$conn = mysqli_connect('localhost', 'TeamA', 'TeamA1234567@', 'test');
$sql = "SELECT * FROM board WHERE post_num={$post_num}";
$result = mysqli_fetch_array(mysqli_query($conn, $sql));
if($result == "")
{
echo $wrong_connection;
}
if(strcmp($result['user_id'], $_SESSION['user_id']))
{
echo $wrong_connection;
}
}
else
{
echo $wrong_connection;
}
?>
</head>
<body>
<div>
<h1>자유게시판</h1>
<form method="POST" action="edit_ok.php">
<div style="height: 500px;display:flex;flex-direction: column;justify-content: space-evenly;">
<input type="text" name="title" placeholder="제목" required="required" value="<?php echo $result['title'] ?>">
<textarea name="body" cols="50" rows="30" placeholder="본문" required="required"><?php echo $result['body'] ?></textarea>
<button type="submit">수정</button>
</div>
</form>
</div>
</body>
</html>