{"id":2341,"date":"2014-10-05T15:57:06","date_gmt":"2014-10-05T06:57:06","guid":{"rendered":"http:\/\/www.happyfam.or.kr\/ysoh\/?p=2341"},"modified":"2016-05-30T11:41:33","modified_gmt":"2016-05-30T02:41:33","slug":"webdbii-%ec%8b%a4%ec%8a%b5%ec%98%88%ec%a0%9c-%ec%86%8c%ec%8a%a4-6","status":"publish","type":"post","link":"https:\/\/www.happyfam.or.kr\/ysoh\/webdbii-%ec%8b%a4%ec%8a%b5%ec%98%88%ec%a0%9c-%ec%86%8c%ec%8a%a4-6\/","title":{"rendered":"WebDB(II) \uc2e4\uc2b5\uc608\uc81c \uc18c\uc2a4 #6"},"content":{"rendered":"<pre class=\"wrap:true lang:php decode:true  \" title=\"examSQL-15.php\">&lt;?php\r\nrequire '.\/dbConn.php';\r\n\r\n$link = mysqli_connect($dbHost, $dbUser, $dbPass); \/\/ MySQL \uc11c\ubc84 \uc5f0\uacb0\r\nif (!$link) { \/\/ DB\uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!link, $link!=true, $link==false \ubaa8\ub450 \ub3d9\uc77c)\r\n    echo \"DB \uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();   \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$db = mysqli_select_db($link, $dbName); \/\/ Database \uc120\ud0dd\r\nif (!$db) {  \/\/ DB\uc120\ud0dd\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!$db, $db!=true, $db==false \ubaa8\ub450 \ub3d9\uc77c)\r\n    echo \"{$dbName} \uc774\ub984\uc758 DB\ub97c \ucc3e\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();  \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$char = mysqli_set_charset($link, \"utf8\"); \/\/ DB \ubb38\uc790\uc14b \uc124\uc815\r\nif (!$char) { \/\/ \ubb38\uc790\uc14b \uc124\uc815\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!$char, $char!=true, $char==false \ubaa8\ub450 \ub3d9\uc77c)\r\n    echo \"UTF-8 \ubb38\uc790\uc14b\uc744 \uc124\uc815\ud558\uc9c0 \ubabb\ud588\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();   \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$sql = \"SELECT `userid`, `passwd`, `name`, `email` FROM `user` WHERE `userid` = '{$_GET[\"userid\"]}'\";\r\n\r\n$result = mysqli_query($link, $sql); \/\/ SQL \uc2e4\ud589\r\nif (!$result) { \/\/ SQL\uc5d0 \uc624\ub958\uac00 \uc788\ub294 \uacbd\uc6b0\r\n    echo \"SQL\uc5d0 \uc624\ub958\uac00 \uc788\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();     \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$row = mysqli_fetch_array($result); \/\/ \uac80\uc0c9\ub41c \ud68c\uc6d0\uc815\ubcf4\ub97c \uac00\uc838\uc634\r\n\r\nmysqli_close($link); \/\/ MySQL \uc5f0\uacb0 \uc885\ub8cc\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=\"UTF-8\"&gt;\r\n        &lt;title&gt;examSQL-15.php&lt;\/title&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;h1&gt;\ud68c\uc6d0\uc815\ubcf4\uc218\uc815&lt;\/h1&gt;\r\n        &lt;form method=\"post\" action=\"examSQL-17.php\"&gt;\r\n            \uc544\uc774\ub514 : &lt;input type=\"text\" name=\"a\" value=\"&lt;?=$row[\"userid\"]?&gt;\" \/&gt;&lt;br\/&gt;\r\n            \ube44\ubc00\ubc88\ud638 : &lt;input type=\"password\" name=\"b\" value=\"&lt;?=$row[\"passwd\"]?&gt;\"\/&gt;&lt;br\/&gt;\r\n            \uc131\uba85 : &lt;input type=\"text\" name=\"c\" value=\"&lt;?=$row[\"name\"]?&gt;\"\/&gt;&lt;br\/&gt;\r\n            \uc774\uba54\uc77c : &lt;input type=\"text\" name=\"d\" value=\"&lt;?=$row[\"email\"]?&gt;\"\/&gt;&lt;br\/&gt;\r\n            &lt;input type=\"submit\" value=\"\ub4f1\ub85d\" \/&gt;\r\n        &lt;\/form&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<pre class=\"wrap:true lang:php decode:true\" title=\"examSQL-16.php\">&lt;?php\r\nrequire '.\/dbConn.php';\r\n\r\n$link = mysqli_connect($dbHost, $dbUser, $dbPass); \/\/ MySQL \uc11c\ubc84 \uc5f0\uacb0\r\nif (!$link) { \/\/ DB\uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!link, $link!=true, $link==false \ubaa8\ub450 \ub3d9\uc77c)\r\n    echo \"DB \uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();   \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$db = mysqli_select_db($link, $dbName); \/\/ Database \uc120\ud0dd\r\nif (!$db) {  \/\/ DB\uc120\ud0dd\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!$db, $db!=true, $db==false \ubaa8\ub450 \ub3d9\uc77c)\r\n    echo \"{$dbName} \uc774\ub984\uc758 DB\ub97c \ucc3e\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();  \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$char = mysqli_set_charset($link, \"utf8\"); \/\/ DB \ubb38\uc790\uc14b \uc124\uc815\r\nif (!$char) { \/\/ \ubb38\uc790\uc14b \uc124\uc815\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!$char, $char!=true, $char==false \ubaa8\ub450 \ub3d9\uc77c)\r\n    echo \"UTF-8 \ubb38\uc790\uc14b\uc744 \uc124\uc815\ud558\uc9c0 \ubabb\ud588\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();   \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$sql = \"SELECT `userid`, `passwd`, `name`, `email` FROM `user` WHERE `userid` = '{$_GET[\"userid\"]}'\";\r\n\r\n$result = mysqli_query($link, $sql); \/\/ SQL \uc2e4\ud589\r\nif (!$result) { \/\/ SQL\uc5d0 \uc624\ub958\uac00 \uc788\ub294 \uacbd\uc6b0\r\n    echo \"SQL\uc5d0 \uc624\ub958\uac00 \uc788\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;\";\r\n    exit();     \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n}\r\n\r\n$row = mysqli_fetch_array($result); \/\/ \uac80\uc0c9\ub41c \ud68c\uc6d0\uc815\ubcf4\ub97c \uac00\uc838\uc634\r\n\r\nmysqli_close($link); \/\/ MySQL \uc5f0\uacb0 \uc885\ub8cc\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=\"UTF-8\"&gt;\r\n        &lt;title&gt;examSQL-16.php&lt;\/title&gt;\r\n        &lt;style&gt;\r\n            .field-name {float:left; width:100px;text-align:right;}\r\n            .field-input input {margin-left: 10px;}\r\n        &lt;\/style&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;h1&gt;\ud68c\uc6d0\uc815\ubcf4\uc218\uc815&lt;\/h1&gt;\r\n        &lt;form method=\"post\" action=\"examSQL-17.php\"&gt;\r\n            &lt;div class=\"field-name\"&gt;\uc544\uc774\ub514 : &lt;\/div&gt;\r\n            &lt;div class=\"field-input\"&gt;&lt;input type=\"text\" value=\"&lt;?= $row[\"userid\"] ?&gt;\" disabled \/&gt;\r\n                &lt;input type=\"hidden\" name=\"a\" value=\"&lt;?= $row[\"userid\"] ?&gt;\" \/&gt;&lt;\/div&gt;\r\n            &lt;div class=\"field-name\"&gt;\ube44\ubc00\ubc88\ud638 : &lt;\/div&gt;\r\n            &lt;div class=\"field-input\"&gt;&lt;input type=\"password\" name=\"b\" value=\"&lt;?= $row[\"passwd\"] ?&gt;\"\/&gt;&lt;\/div&gt;\r\n            &lt;div class=\"field-name\"&gt;\uc131\uba85 : &lt;\/div&gt;\r\n            &lt;div class=\"field-input\"&gt;&lt;input type=\"text\" name=\"c\" value=\"&lt;?= $row[\"name\"] ?&gt;\"\/&gt;&lt;\/div&gt;\r\n            &lt;div class=\"field-name\"&gt;\uc774\uba54\uc77c : &lt;\/div&gt;\r\n            &lt;div class=\"field-input\"&gt;&lt;input type=\"text\" name=\"d\" value=\"&lt;?= $row[\"email\"] ?&gt;\"\/&gt;&lt;\/div&gt;\r\n            &lt;div class=\"field-name\"&gt;&amp;nbsp&lt;\/div&gt;\r\n            &lt;div class=\"field-input\"&gt;&lt;input type=\"submit\" value=\"\ub4f1\ub85d\" \/&gt;&lt;\/div&gt;\r\n        &lt;\/form&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<pre class=\"wrap:true lang:php decode:true \" title=\"examSQL-17.php\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=\"UTF-8\"&gt;\r\n        &lt;title&gt;examSQL-17.php&lt;\/title&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;?php\r\n        require '.\/dbConn.php';\r\n\r\n        $link = mysqli_connect($dbHost, $dbUser, $dbPass); \/\/ MySQL \uc11c\ubc84 \uc5f0\uacb0\r\n        if (!$link) { \/\/ DB\uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!link, $link!=true, $link==false \ubaa8\ub450 \ub3d9\uc77c)\r\n            echo \"DB \uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.\";\r\n            exit();   \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n        }\r\n\r\n        $db = mysqli_select_db($link, $dbName); \/\/ Database \uc120\ud0dd\r\n        if (!$db) {  \/\/ DB\uc120\ud0dd\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!$db, $db!=true, $db==false \ubaa8\ub450 \ub3d9\uc77c)\r\n            echo \"{$dbName} \uc774\ub984\uc758 DB\ub97c \ucc3e\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.\";\r\n            exit();  \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n        }\r\n\r\n        $char = mysqli_set_charset($link, \"utf8\"); \/\/ DB \ubb38\uc790\uc14b \uc124\uc815\r\n        if (!$char) { \/\/ \ubb38\uc790\uc14b \uc124\uc815\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!$char, $char!=true, $char==false \ubaa8\ub450 \ub3d9\uc77c)\r\n            echo \"UTF-8 \ubb38\uc790\uc14b\uc744 \uc124\uc815\ud558\uc9c0 \ubabb\ud588\uc2b5\ub2c8\ub2e4.\";\r\n            exit();   \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n        }\r\n\r\n        $sql = \"UPDATE `user` SET `passwd` = '{$_POST[\"b\"]}', `name` = '{$_POST[\"c\"]}', `email` = '{$_POST[\"d\"]}' WHERE `userid` = '{$_POST[\"a\"]}'\";\r\n        echo $sql;\r\n\r\n        $result = mysqli_query($link, $sql); \/\/ SQL \uc2e4\ud589\r\n        if (!$result) { \/\/ SQL\uc5d0 \uc624\ub958\uac00 \uc788\ub294 \uacbd\uc6b0\r\n            echo \"SQL\uc5d0 \uc624\ub958\uac00 \uc788\uc2b5\ub2c8\ub2e4.\";\r\n            exit();     \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc\r\n        }\r\n\r\n        $num = mysqli_affected_rows($link);\r\n        if ($num == 0) {\r\n            echo \"\uc218\uc815\ub41c \ub0b4\uc6a9\uc774 \uc5c6\uc2b5\ub2c8\ub2e4.\";\r\n        } else {\r\n            echo \"\uc815\ubcf4\uac00 \uc218\uc815\ub418\uc5c8\uc2b5\ub2c8\ub2e4.\";\r\n        }\r\n\r\n        mysqli_close($link); \/\/ MySQL \uc5f0\uacb0 \uc885\ub8cc\r\n        ?&gt;\r\n        &lt;a href=\".\/examSQL-13.php\"&gt;\ubaa9\ub85d\uc73c\ub85c&lt;\/a&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php require &#8216;.\/dbConn.php&#8217;; $link = mysqli_connect($dbHost, $dbUser, $dbPass); \/\/ MySQL \uc11c\ubc84 \uc5f0\uacb0 if (!$link) { \/\/ DB\uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!link, $link!=true, $link==false \ubaa8\ub450 \ub3d9\uc77c) echo &#8220;DB \uc5f0\uacb0\uc5d0 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.&lt;br\/&gt;&#8221;; exit(); \/\/ \ud504\ub85c\uadf8\ub7a8 \uc885\ub8cc } $db = mysqli_select_db($link, $dbName); \/\/ Database \uc120\ud0dd if (!$db) { \/\/ DB\uc120\ud0dd\uc5d0 \uc2e4\ud328\ud55c \uacbd\uc6b0 ($!$db, $db!=true, $db==false \ubaa8\ub450 \ub3d9\uc77c) echo &#8220;{$dbName} \uc774\ub984\uc758\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.happyfam.or.kr\/ysoh\/webdbii-%ec%8b%a4%ec%8a%b5%ec%98%88%ec%a0%9c-%ec%86%8c%ec%8a%a4-6\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[134,2],"tags":[233,21,34,40,53],"class_list":["post-2341","post","type-post","status-publish","format-standard","hentry","category-webdbii","category-2","tag-database","tag-html","tag-mysql","tag-php","tag-webdb"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p776QY-BL","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/posts\/2341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/comments?post=2341"}],"version-history":[{"count":0,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/posts\/2341\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/media?parent=2341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/categories?post=2341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/tags?post=2341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}