웹 페이지 구축 - 자유게시판
게시판 글 또한 DB에 저장되어야 하기 때문에 sql 을 만들어서 넣어보도록 하겠습니다.
/var/www/html/freeboard에 위치해야 합니다.
freeboard.sql
데이터 베이스에 정상적으로 들어간 것을 확인할 수 있습니다.
list.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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | <?php $scale = 5; include_once "../dbconn.php"; $sql = "select * from freeboard order by num desc"; $result = mysql_query($sql, $connect); ?> <html> <META http-equiv='Content-Type' cotent='text/html; charset=Korean'> <head> <title>:Welcome to My PHP World!:</title> <link rel='stylesheet' href='../style.css' type='text/css'> </head> <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'> <table border='0' cellspacing='0' cellpadding='0' width='766' align='center'> <tr> <td colspan='5' height='25'> <img src='img/freeboard_title.gif'> </td> </tr> <tr> <td background='img/bss_bg.gif'> <img border='0' src='img/blank.gif' width='1' height='3'> </td> </tr> <tr><td height='10'></td></tr> <?php $total_record = mysql_num_rows($result);?> <tr> <td align='right' colspan='5' height='20'>Total <?php echo $total_record;?> </td> </tr> <tr> <td> <table border='0' cellspacing='0' cellpadding='0' width='100%' class='txt'> <tr bgcolor='#5ab2c8'> <td colspan='5' height='1'> </td> </tr> <tr bgcolor='#d2eaf0' height='25'> <td width='50' align='center'> <strong>Num</strong></td> <td width='450' align='center'><strong>Title</strong></td> <td width='76' align='center'><strong>Writer</strong></td> <td width='145' align='center'><strong>Date</strong></td> <td widht='55' align='center'><strong>Cnt</strong></td> </tr> <tr bgcolor='#5ab2c8'> <td colspan='5' height='1'></td> </tr> <?php if($total_record % $scale == 0) { $total_page = floor($total_record/$scale); } else { $total_page = floor($total_record/$scale) + 1; } if(!$page) { $page = 1; } $start = ($page - 1) * $scale; $number = $total_record - $start; for($i=$start; $i<$start+$scale && $i < $total_record; $i++) { mysql_data_seek($result, $i); $row = mysql_fetch_array($result); $day = $row['regist_day']; echo" <tr height='25'> <td align='center'>$number</td> <td img src='img/record_id.gif' border='0'> <a href='view.php?num=$row[num]&page=$page'>$row[subject]</a></td> <td align='center'>$row[name]</td> <td align='center'>$day</td> <td align='center'>$row[hit]</td> </tr> <tr bgcolor='#cccccc' height='1'> <td colspan='5'></td> </tr> "; $number--; } ?> <tr> <td colspan='5' height='20'></td> </tr> <tr height='25'> <td colspan='5' align='center'> <?php for($i=1; $i<$total_page; $i++) { if($page == $i) { echo "<font color='4c5317'><b>[$i]</b></font>"; } else { echo "<a href='list.php?page=$i'><font color='4c5317'>[$i]</font></a>"; } } ?> </td> </tr> <tr bgcolor='#cccccc' height='1'> <td colspan='5'> </td> </tr> </table> </td> </tr> </table> <table width='766' align='center' border='0' cellpadding='0' cellspacing='0' bgcolor='#d2eaf0'> <tr height='5'> <td></td> </tr> <form name=serchForm method=post action='search.php'> <tr> <td> <select name='find' class='txt'> <option value='subject'>From the title</option> <option value='content'>From the content</option> <option value='name'>From the name</option> </select> <input type='text' name='search' size='10'> <input type='image' src='img/i_search.gif' align='absmiddle' border='0'> </td> <td align='right'> <a href='write_form.php'> <img src='img/i_write.gif' align='absmiddle' border='0'> </a> <a href='list.php'> <img src='img/i_list.gif' border='0'> </a> </td> </tr> <tr height='5'> <td></td> </tr> <tr bgcolor='#5ab2c8' height='1'> <td colspan='2'></td> </tr> </form> </table> </body> </html> | cs |
search.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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | <?php $scale = 5; include_once "../dbconn.php"; $sql = "select * from freeboard where $find like '$search%' order by num desc"; $result = mysql_query($sql, $connect); ?> <html> <META http-equiv='Content-Type' content='text/html; carset=Korean'> <head> <title>:: Welcome to My PHP World! ::</title> <link rel='stylesheet' href='../style.css' type='text/css'> </head> <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'> <table border='0' cellspacing='0' cellpadding='0' width='766' align='center'> <tr> <td colspan='5' height='25'> <img src='img/freeboard_title.gif'> </td> </tr> <tr> <td background='img/bbs_bg.gif'> <img border='0' src='img/blank.gif' width='1' height='3'> </td> </tr> <tr><td height='10'></td></tr> <?php $total_record = mysql_num_rows($result); ?> <tr> <td align='right' colspan='5' height='20'>Total <?php echo $total_record; ?> </td> </tr> <tr> <td> <table border='0' cellspacing='0' cellpadding='0' width='100%' class='txt'> <tr bgcolor='#5ab2c8'> <td colspan='5' height='1'> </td> </tr> <tr bgcolor='#d2eaf0' height='25'> <td width='50' align='center'><strong>Num</strong></td> <td width='450' align='center'><strong>Title</strong></td> <td width='76' align='center'><strong>Writer</strong></td> <td width='145' align='center'><strong>Date</strong></td> <td width='55' align='center'><strong>Cnt</strong></td> </tr> <tr bgcolor='#5ab2c8'> <td colspan='5' height='1'></td> </tr> <?php if($total_record % $scale == 0) { $total_page = floor($total_record/$scale); } else { $total_page = floor($total_record/$scale) + 1; } if(!$page) { $page = 1; } $start = ($page - 1) * $scale; for($i=$start; $i<$start+$scale && $i < $total_record; $i++) { mysql_data_seek($result, $i); } $row = mysql_fetch_array($result); $day = $row['regist_day']; echo" <tr height='25'> <td align='center'>$row[num]</td> <td> <img src='img/record_id.gif' border='0'> <a href='view.php?num=$row[num]&page=$page'>$row[subject]</a> </td> <td align='center'>$row[name]</td> <td align='center'>$day</td> <td align='center'>$row[hit]</td> </tr> <tr bgcolor='#cccccc' height='1'> <td colspan='5'></td> </tr> "; ?> <tr> <td colspan='5' height='20'></td> </tr> <tr height='25'> <td colspan='5' align='center'> <?php for($i=1; $i<=$total_page; $i++) { if($page == $i) { echo " <font color='4c5317'><b>[$i]</b></font>"; } else { echo " <a href='list.php?page=$i'> <font color='4c5317'>[$i]</font> </a>"; } } ?> </td> </tr> <tr bgcolor='#cccccc' height='1'> <td colspan='5'></td> </tr> </table> </td> </tr> </table> <table width='766' align='center' border='0' cellpadding='0' cellspacing='0' bgcolor='#d2eaf0'> <tr height='5'><td></td></tr> <form name='searchForm' method='post' action='search.php'> <tr> <td> <select name='find' class='txt'> <option value='subject'>From the subject</option> <option value='content'>From the content</option> <option value='name'>From the name</option> </select> <input type='text' name='search' size='10'> <input type='image' src='img/i_search.gif' align='absmiddle' border='0'> </td> <td align='right'> <a href='write_from.php'> <img src='img/i_write.gif' align='absmiddle' border='0'> </a> </td> </tr> </form> <tr height='5'><td></td></tr> <tr bgcolor='#5ab2c8'> <td colspan='2'> </td> </tr> </table> </body> </html> | cs |
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 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 | <html> <head> <title>:: Welcome to My PHP World! ::</title> <link rel='stylesheet' href='../sytle.css' type='text/css'> </head> <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'> <table width='766' align='center' border='0' cellspacing='0' cellpadding='0'> <form name='writeform' action='insert.php' method='post'> <tr> <td colspan='6' height='25'> <img src='img/freeboard_title.gif'> </td> </tr> <tr> <td background='img/bss_bg.gif'> <img border='0' src='img/freeboard_title.gif' width='1' height='3'> </td> </tr> <tr><td height='10'></td></tr> <td align='center' colspan='2'> <table width='776' border='0' cellspacing='0' cellpadding='0' class='txt' bgcolor='#f7f7f2'> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <tr bgcolor='#d2eaf0' height='20'><td width='100%'> <b>Name, PostNum, Password</b></td></tr> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <tr> <td> <table width='100%' border='0' cellspacing='0' cellpadding='0' class='txt'> <tr height='25'> <td align='right' width='100'>Name </td> <td align='left'> <input style='font-size:9pt; border:1px; solid' type='text' name='name' size='25' maxlength='16' border='1'> </td> </tr> <tr height='25'> <td align='right'>Passwd </td> <td align='left'> <input style='font-size:9pt; border:1px; solid' type='password' name='passwd' size='25' maxlength='16' border='1'> </td> </tr> </table> </td> </tr> <tr height='1' bgcolor='#5ab2c8'> <td colspan='2'></td> </tr> <tr bgcolor='#d2eaf0' height='20'> <td colspan='2'> <b>Write coment</b></td> </tr> <tr height='1' bgcolor='#5ab2c8'> <td colspan='2'></td> </tr> <tr bgcolor='#d2eaf0' height='20'> <td colspan='2'> <b>Write coment</b></td> </tr> <tr height='1' bgcolor='#5ab2c8'> <td colspan='5'></td> </tr> <tr> <td colspan='2'> <table width='100%' border='0' cellspacing='0' cellpadding='0' class='txt'> <tr> <td height='25'> Title <input style='font-size:9pt; border:1px; solid' type='text' name='subject' size='50' maxlength='100'> </td> </tr> <tr valign='top'> <td align='center'> <p align='left'> Content <textarea style='font-size:9pt; border:1px; solid' name='content' style=background-img:url('imb/bss_text_line.gif'); cols='74' row='14' wrap='virtual'></textarea> </td> </tr> <tr height='20'><td></td></tr> <tr height='1' bgcolor='#5ab2c8'></td></td></tr> <tr> <td height='30' align='center' valign='top' bgcolor='#ffffff'> <br> <input type='image' src="img/i_write.gif" align='absmiddle' border='0'> <a href='list.php'> <img style='cursor:hand' src='img/i_list.gif' align='absmiddle' border='0'> </a> </td> </tr> </table> </td> </tr> </table> </td> </form> </table> </body> </html> | cs |
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 | <?php $name = $_POST['name']; $passwd = $_POST['passwd']; $subject = $_POST['subject']; $content = $_POST['content']; if(!$name) { echo" <script> window.alert('Input Your name.'); history.go(-1); </script> "; exit; } if(!$passwd) { echo" <script> window.alert('Input password.'); history.go(-1); </script> "; exit; } if(!$subject) { echo" <script> window.alert('Input title.'); history.go(-1); </script> "; exit; } if(!$content) { echo" <script> window.alert('Input content.'); history.go(-1); </script> "; exit; } include_once "../dbconn.php"; $regist_day = date("Y-m-s (H:i)"); $ip = $_SERVER['REMOTE_ADDR']; $sql = "insert into freeboard(name, passwd, subject, content, regist_day, hit, ip) "; $sql .= "values('$name', '$passwd', '$subject', '$content', '$regist_day', 0, '$ip')"; mysql_query($sql, $connect); mysql_close(); Header("Location:list.php"); ?> | cs |
view.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 | <?php session_start(); ?> <html> <head> <title>:: Welcome to My PHP World!::</title> <link rel='stylesheet' href='../style.css' type='text/css'> </head> <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'> <table width='776' border='0' cellspacing='0' cellpadding='0' align='center'> <tr> <td colspan='6' height='25'> <img src='img/freeboard_title.gif'> </td> </tr> <tr> <td background='img/bbs_bg.gif'> <img border='0' src='img/blank.gif' width='1' height='3'> </td> </tr> <tr><td height='10'></td></tr> <tr><td height='10'></td></tr> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <?php include_once "../dbconn.php"; $num = $_GET['num']; $sql = "select * from freeboard where num=$num"; $result = mysql_query($sql, $connect); $row = mysql_fetch_array($result); $content = str_replace("\n", "<br>", $row[content]); $content = str_replace(" ", " ", $content); $content = str_replace(" ", " ", $row[subject]); ?> <tr bgcolor='#d2eaf0' height='30'> <td> <b> <?php echo $row[subject] ?> </td> </tr> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <tr> <td> <table width='100%' border='0' cellspacing='10' cellpadding='0' class='txt'> <tr> <td> <b>Writer:<?php $row[name]; ?></b> <?php echo $row[regist_day]; ?> </td> </tr> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <tr> <td><br><?php echo $content; ?> </td> </tr> </table> </td> </tr> <tr height='20'> <td align='right'> <font size=-2>IP<?php echo $row['ip']; ?></font> </td> </tr> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <tr> <td> <table border='0' cellspacing='0' cellpadding='0' width='100%'> <tr height='10'><td></td></tr> <?php if($userid == "admin") { echo" <tr> <td align='center'> <a href='modify_form.php?num=$num&page=$page'> <img src='img/i_edit.gif' border='0'> </a> <a href='delete.php?num=$num&page=$page'> <img src='img/i_del.gif' border='0'> </a> <a href='list.php?page=$page'> <img src='img/i_list.gif' border='0'> </a> </td> </tr> "; } else { echo" <tr> <td align='center'> <a href='passwd_form.php?case=modify&num=$num&page=$page'> <img src='img/i_edit.gif' border='0'> </a> <a href='passwd_form.php?case=delete&num=$num&page=$page'> <img src='img/i_del.gif' border='0'> </a> <a href='list.php?page=$page'> <img src='img/i_list.gif' border='0'> </a> </td> </tr> "; } ?> </table> </td> </tr> </table> </body> </html> <?php $hit = $row['hit']; $hit++; $sql = "update freeboard set hit=$hit where num=$row[num]"; mysql_query($sql, $connect); mysql_close(); ?> | cs |
passwd_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 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 | <html> <head> <META http-equiv='Content-Type' content='text/html; charset=EUC-KR'> <title>PASSWORD</title> <style type='text/css'> td,p,div,input,th,select{font-size:9pt;}.c1{BORDER-RIGHT:black 1px solid; BORDER-TOP:black 1px solid; BORDER-LEFT:black 1px solid; BORDER-BOTTOM:black 1px solid;}.hand{cursor:hand;} </style> </head> <body bgcolor='#ffffff' marginheight='0' topmargin='0' OnLoad='javascript:pwform.passwd.focus()'> <br> <script type='text/javascript'> function go() { if(document.pwform.passwd.value == "") { alert('Input Password'); return false; } document.pwform.submit(); } function clean() { document.pwform.passwd.value=""; } </script> <div align='center'> <?php $num = $_GET['num']; $page = $_GET['page']; $case = $_GET['sel']; if($case == "modify") { echo " <form name='pwform' method='post' action='modify_form.php?num=$num&page=$page'> "; } else { echo " <form name='pwform' method='post' action='delete.php?num=$num&page=$page'> "; } ?> <table cellpadding='0' cellspacing='0' border='0' width='306'> <tr height='1' bgcolor='#292e5f'><td></td></tr> <tr height='18'> <td bgcolor='#cee3f7'> <img src='img/bbs_check.gif'> <font color=003366><b>Input Password</b></font> </td> </tr> <tr height='1' bgcolor='#292e5f'><td></td></tr> <tr height='20' bgcolor='#f7f7f2'><td></td></tr> <tr> <td valign='top' align='center'> <table cellpadding='0' cellspacing='5' border='0' width='100%' bgcolor='#f7f7f2'> <tr> <td width='80' align='right'> <font size='-1'>Password</font> </td> <td width='170'> <input class='c1' type='password' name='passwd' size='15' maxlength='10'> </td> </tr> <tr> <td colspan='2' align='center'> <img src='img/button_ok.gif' align='absmiddle' class='hand' onclick='go()'> <img src='img/button_rewrite.gif' align='absmiddle' class='hand' onclick='clean()'> <img src='img/button_close.gif' align='absmiddle' class='hand' onclick='javascript:history.back()'> </td> </tr> </table> </td> </tr> <tr height='20' bgcolor='#f7f7f2'><td></td></tr> <tr height='1' bgcolor='#292e5f'><td></td></tr> </table> </div> </body> </html> | cs |
modify_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 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 | <?php session_start(); include_once "../dbconn.php"; $num = $_GET['num']; $passwd = $_POST['passwd']; $userid = $_POST['id']; //GET or POST $sql = "select * from freeboard where num=$num"; $result = mysql_query($sql, $connect); $row = mysql_fetch_array($result); if($passwd != $row['passwd'] and $userid != 'admin') { echo " <script> alert('Incorrect Password'); history.go(-1); </script> "; exit; } ?> <html> <head> <title>:: Welcome to My PHP World! ::</title> <link rel='stylesheet' href='../style.css' type='text/css'> </head> <table border='0' cellspacing='0' cellpadding='0' width='766' align='center'> <tr> <td colspan='6' height='25'> <img src='img/freeboard_title.gif'> </td> </tr> <tr> <td background='img/bbs_bg.gif'> <img border='0' src='img/blank.gif' width='1' height='3'> </td> </tr> <tr><td height='10'></td></tr> <form name='modifyform' action='modify.php?num=<?php echo $num; ?>&page=<?php echo $page; ?>' method='post'> <tr> <td align='center' colspan='2'> <table width='766' border='0' cellspacing='0' cellpadding='0' class='txt' bgcolor='#f7f7f2'> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <tr bgcolor='#d2eaf0' height='20'> <td width='100%'> <b>Name, PostNum, Password</b> </td> </tr> <tr height='1' bgcolor='#5ab2c8'><td></td></tr> <tr> <td> <table width='100%' border='0' cellspacing='0' cellpadding='0' class='txt'> <tr height='25'> <td align='right' width='100'>Name </td> <td align='left'> <input style='font-size:9pt; border:1px solid' type='text' name='name' value="<?php echo $row[name]; ?>" size='25' maxlength='16'> </td> </tr> <tr height='25'> <td align='right'>Password </td> <td align='left'> <input style='font-size:9pt; border:1px; solid' type='password' name='passwd' value="<?php echo $row['passwd']; ?>", size='25' maxlength='16'> </td> </tr> </table> </td> </tr> <tr height='1' bgcolor='#5ab2c8'><td colspan='2'></td></tr> <tr bgcolor='#d2eaf0' height='20'> <td colspan='2'> <b>Leave a message.</b> </td> </tr> <tr height='1' bgcolor='#5ab2c8'><td colspan='5'></td></tr> <tr> <td colspan='2'> <table width='100%' border='0' cellspacing='0'cellpadding='0' class='txt'> <tr> <td height='25'> Title <input style='font-size:9pt; border:1px; solid' type='text' name='subject' value="<?php echo $row['subject'];?>" size='50' maxlength='100'> </td> </tr> <tr><td height='2'> </td></tr> <tr valign='top'> <td> Content <textarea style='font-size:9pt; border:1px; solid' name='content' style="background-image:url('img/bbs_text_line.gif');" cols='74' rows='14' wrap='virtual'> <?php echo $row['content']; ?> </textarea> </td> </tr> <tr height='20'><td></td></tr> <tr height='1' bgcolor='#5ab2c8'><td colspan='5'></td></tr> <tr> <td height='30' align='center' valign='top' bgcolor='#ffffff'> <br> <input type='image' src='img/i_write.gif' align='absmiddle' border='0'> <a href="list.php?page=<?php echo $page;?>"> <img style='cursor:hand' src='img/i_list.gif' align='absmiddle' border='0'> </a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </form> </table> </html> | cs |
modify.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 | <?php error_reporting(E_ALL); ini_set("display_erros", 1); $num = $_GET['num']; $page = $_POST['page']; $name = $_POST['name']; $passwd = $_POST['passwd']; $subject = $_POST['subject']; $content = $_POST['content']; if(!$name) { echo" <script> window.alert('Input Your name.'); history.go(-1); </script> "; exit; } if(!$passwd) { echo" <script> window.alert('Input Your Password.'); history.go(-1); </script> "; exit; } if(!$content) { echo" <script> window.alert('Input Content.'); history.go(-1); </script> "; exit; } if(!$subject) { echo" <script> window.alert('Input Title.'); history.go(-1); </script> "; exit; } include_once "../dbconn.php"; $regist_day = date("Y-m-d (H:i)"); $ip = $_SERVER['REMOTE_ADDR']; $sql = "update freeboard set name='$name', passwd='$passwd', subject='$subject', content='$content', regist_day='$regist_day', ip='$ip' where num='$num'"; mysql_query($sql, $connect); mysql_close(); Header("Location:list.php?num=$num&page=$page"); ?> | cs |
delete.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 | <?php session_start(); include_once "../dbconn.php"; $num = $_GET['num']; $page = $_GET['page']; $passwd = $_POST['passwd']; $userid = $_GET['id']; echo "<script>window.alert('$passwd');"; $sql = "select passwd from freeboard where num=$num"; $result = mysql_query($sql, $connect); $row = mysql_fetch_array($result); if($passwd != $row['passwd'] and $userid !='admin') { echo" <script> window.alert('Incorrect Password'); history.go(-1); </script> "; exit; } else { $sql = "delete from freeboard where num=$num"; mysql_query($sql, $connect); mysql_close(); Header("location:list.php?page=$page"); } ?> | cs |
'High Level Technique > Web Hacking' 카테고리의 다른 글
웹 페이지 구축 - 회원가입, 로그인 (0) | 2016.11.10 |
---|---|
웹 페이지 구축 - index, top (0) | 2016.11.08 |
쿠키와 세션 (0) | 2016.11.08 |
PHP MySQL 연동 (0) | 2016.11.07 |
MySQL (0) | 2016.11.07 |