{"id":469,"date":"2024-04-24T01:35:58","date_gmt":"2024-04-24T01:35:58","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=469"},"modified":"2024-04-24T04:04:12","modified_gmt":"2024-04-24T04:04:12","slug":"form-validation5url-check","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/04\/24\/form-validation5url-check\/","title":{"rendered":"\ud3fc \uc720\ud6a8\uc131 \ud655\uc778\ud558\uae30(Form validation)(5),URL\uccb4\ud06c(URL check)"},"content":{"rendered":"\n<p>\uceec\ub7ec\ub85c \uac15\uc870\ub41c \ubd80\ubd84\uc740 \ubaa8\ub450 \uc0c8\ub85c \ucd94\uac00\ub41c \ucf54\ub4dc \uc785\ub2c8\ub2e4.<br>\ub179\uc0c9\uc740 \uc0c8\ub86d\uac8c \ucd94\uac00\ub41c \ubd80\ubd84\uc774\ub098 \uae30\uc874 \ubd80\ubd84\uacfc \uc720\uc0ac\ud55c \ubd80\ubd84\uc785\ub2c8\ub2e4.<br>\ub178\ub780\uc0c9 \ubd80\ubd84\uc740 URL\uc744 \ud655\uc778\ud558\uae30 \uc704\ud55c \ubd80\ubd84\uc785\ub2c8\ub2e4.<br>\uc624\ub80c\uc9c0\uc0c9 \ubd80\ubd84\uc740 URL\uc744 \uccb4\ud06c\ud558\uae30 \uc704\ud55c \uc815\uaddc\ud45c\ud604\uc2dd \ubd80\ubd84\uc785\ub2c8\ub2e4.<br>URL\ud655\uc778 \ubd80\ubd84\ub3c4 \uc774\uba54\uc77c \ud655\uc778 \ubd80\ubd84\uacfc \ud06c\uac8c \ub2e4\ub974\uc9c0 \uc54a\uc9c0\ub9cc \ud544\uc218 \ud56d\ubaa9\uc774 \uc544\ub2c8\uae30 \ub54c\ubb38\uc5d0 \uacf5\ubc31\ud655\uc778\uc740 \ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. <\/p>\n\n\n\n<p>All parts highlighted in color are newly added codes.<br>The Green part is a newly added part and is similar to the existing part.<br>The yellow part is for checking the URL.<br>The orange part is the regular expression part for checking URL.<br>The URL confirmation part is not much different from the email confirmation part, but since it is not required, space checking is not performed.<\/p>\n\n\n\n<p>\uc544\ub798\uc758 \ub9c1\ud06c\ub97c \ud1b5\ud574\uc11c \ud14c\uc2a4\ud2b8 \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4<br>You can test it through the link below<br><a href=\"https:\/\/freelifemakers.org\/lec\/form5.php\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/freelifemakers.org\/lec\/form5.php<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>form5.php\n&lt;?php\n\n$fileName = \".\/form_action5.php\";\n\nif(!is_file($fileName)){\n    $form_action_name = basename($_SERVER&#91;'PHP_SELF']);\n}else{\n    $form_action_name = \".\/form_action5.php\";\n}\n    ?&gt;\n\n&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n    &lt;head&gt;\n      &lt;title&gt;Bootstrap 5 webform&lt;\/title&gt;\n      &lt;!--\uc774 \ubd80\ubd84\uc740 html\ucf54\uba58\ud2b8 \uc601\uc5ed This part is the html comment area,\ub9c8\uc784\ud0c0\uc785\uc124\uc815 Mime type settings\/\/--&gt;\n      &lt;meta charset=\"utf-8\"&gt;\n      &lt;!-- \ubaa8\ubc14\uc77c\ud3f0 \uc2a4\ud06c\ub9b0 \uc635\uc158 Mobile phone screen options\/\/--&gt;\n      &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;\n      &lt;!--\ubd80\ud2b8\uc2a4\ud2b8\ub7a95 CDN\ubc29\uc2dd \ub9c1\ud06c Bootstrap 5 CDN method link\/\/--&gt;\n      &lt;link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.2.3\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\n      &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.2.3\/dist\/js\/bootstrap.bundle.min.js\"&gt;&lt;\/script&gt;\n      &lt;!-- \ud3fc\uccb4\ud06c innerHTML\uacbd\uace0 \uba54\uc2dc\uc9c0 \ucd9c\ub825 --&gt;\n      &lt;!-- Form check innerHTML warning message output \/\/--&gt;\n      &lt;script&gt;\n        function frmSubmit(){\n            \n           \/\/name input box\uc5d0\uc11c \uac12\uc744 \uac00\uc838\uc624\uae30\n           \/\/Get value from name input box\n           var frmName     = document.getElementById(\"name\").value;\n           var frmEmail    = document.getElementById(\"email\").value;  \n          <mark style=\"background-color:rgba(0, 0, 0, 0);color:#dabd15\" class=\"has-inline-color\"> var frmWebsite  = document.getElementById(\"website\").value; <\/mark>    \n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">           var frmTitle    = document.getElementById(\"title\").value; <\/mark>                            \n           var frmPwd      = document.getElementById(\"pwd\").value;\n           <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">var frmComment  = document.getElementById(\"comment\").value;<\/mark>\n\n           \/\/\uc815\uaddc\ud45c\ud604\uc2dd\uacfc \ube44\uad50\ud558\uc5ec \uc774\uba54\uc77c \ubc0f url\ud14c\uc2a4\ud2b8\n           \/\/Test the email and url against the regular expression\n           var regex = \/^&#91;\\w-]+(\\.&#91;\\w-]+)*@(&#91;\\w-]+\\.)+&#91;a-zA-Z]{2,7}$\/;\n           var emailCheck = regex.test(frmEmail); \n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-orange-color\">           var regexURL = \/^(https?:\\\/\\\/)?(&#91;a-z0-9-]+\\.)+&#91;a-z]{2,7}(\\\/\\S*)?$\/i;\n           var URLCheck = regexURL.test(frmWebsite);<\/mark>\n\n           \/\/ \uc6f9\uc0ac\uc774\ud2b8\uc8fc\uc18c\uac00 \uacf5\ubc31\uc774\uba74 \ud655\uc778\ud558\uc9c0 \uc54a\uc74c.\n           \/\/ If the website field is blank, it does not check.\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#dabd15\" class=\"has-inline-color\">           if(frmWebsite == \"\"){\n            URLCheck = true;\n           }  <\/mark><mark style=\"background-color:rgba(0, 0, 0, 0);color:#c2a506\" class=\"has-inline-color\">    <\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">     \n<\/mark>\n           \/\/\uc5d0\ub7ec\uba54\uc138\uc9c0 \ucd08\uae30\ud654\n           \/\/Reset error message\n           errorName.innerHTML = \"\";\n           errorEmail.innerHTML = \"\";           \n           errorPwd.innerHTML = \"\";\n           <mark style=\"background-color:rgba(0, 0, 0, 0);color:#dabd15\" class=\"has-inline-color\">errorWebsite.innerHTML = \"\";<\/mark>\n           <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">errorTitle.innerHTML = \"\";<\/mark>\n           <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">errorComment.innerHTML = \"\";<\/mark>\n           \n           \/\/\uac12\uc758 \uc874\uc7ac \uc5ec\ubd80\uccb4\ud06c ,\uacf5\ubc31\uc774\uba74 \uacbd\uace0\ucc3d \ub744\uc6b0\uae30\n           \/\/Check whether value exists, if blank, display warning window\n           if(frmName == \"\"){\n            errorName.innerHTML =\"&lt;p&gt;\uc774\ub984\uc744 \uc785\ub825\ud558\uc138\uc694(Please Enter Your Name)&lt;\/p&gt;\";\n            return;\n           }else if(frmEmail == \"\"){\n            errorEmail.innerHTML =\"&lt;p&gt;Email\uc744 \uc785\ub825\ud558\uc138\uc694(Please Enter Your Email)&lt;\/p&gt;\";\n            return;\n           }else if(emailCheck == false){   \n            errorEmail.innerHTML =\"&lt;p&gt;\uc815\ud655\ud55c Email\uc744 \uc785\ub825\ud558\uc138\uc694(Please enter the correct Email)&lt;\/p&gt;\";       \n            return; \n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#dabd15\" class=\"has-inline-color\">           }else if(URLCheck == false){ \n            errorWebsite.innerHTML =\"&lt;p&gt;\uc815\ud655\ud55c URL\uc744 \uc785\ub825\ud558\uc138\uc694(Please enter the correct URL)&lt;\/p&gt;\";       \n            return; <\/mark>\n           }else if(frmTitle == \"\"){\n            errorTitle.innerHTML =\"&lt;p&gt;\uc81c\ubaa9\uc744 \uc785\ub825\ud558\uc138\uc694(Please enter the post title)&lt;\/p&gt;\";\n            return;                                  \n           }else if(frmPwd == \"\"){\n            errorPwd.innerHTML =\"&lt;p&gt;\ud328\uc2a4\uc6cc\ub4dc\ub97c \uc785\ub825\ud558\uc138\uc694(Please Enter Your Password)&lt;\/p&gt;\";\n            return;\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">           }else if(frmComment == \"\"){\n            errorComment.innerHTML =\"&lt;p&gt;\uae00\ub0b4\uc6a9\uc744 \uc785\ub825\ud558\uc138\uc694(Please Enter The post content)&lt;\/p&gt;\";\n            return;<\/mark>            \n           }else{\n            frm.submit();\n           }\n        }\n      &lt;\/script&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;  \n    &lt;div class=\"container-sm\"&gt;    \n        &lt;form id=\"frm\" action=\"&lt;?php echo $form_action_name; ?&gt;\" method=\"post\"&gt;\n        &lt;div class=\"mb-3\"&gt;\n            &lt;label for=\"name\" class=\"form-label\"&gt;\uc774\ub984(Name):&lt;\/label&gt;\n            &lt;input type=\"text\" class=\"form-control\" id=\"name\" placeholder=\"\ub2f9\uc2e0\uc758 \uc774\ub984\uc744 \uc785\ub825\ud558\uc138\uc694(Pleas enter your name)\" name=\"name\" required&gt;\n            &lt;div id=\"errorName\"&gt;&lt;\/div&gt;\n        &lt;\/div&gt;\n\n        &lt;div class=\"mb-3\"&gt;\n        &lt;label for=\"email\" class=\"form-label\"&gt;Email:&lt;\/label&gt;\n            &lt;input type=\"text\" class=\"form-control\" id=\"email\" placeholder=\"ID@exmale.com\" name=\"email\" required&gt;\n            &lt;div id=\"errorEmail\"&gt;&lt;\/div&gt;\n        &lt;\/div&gt;\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#dabd15\" class=\"has-inline-color\">        &lt;div class=\"mb-3\"&gt;\n        &lt;label for=\"website\" class=\"form-label\"&gt;Website:&lt;\/label&gt;\n            &lt;input type=\"text\" class=\"form-control\" id=\"website\" placeholder=\"example.com\" name=\"website\"&gt;\n            &lt;div id=\"errorWebsite\"&gt;&lt;\/div&gt; \n        &lt;\/div&gt;<\/mark>\n        \n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">        &lt;div class=\"mb-3\"&gt;\n            &lt;label for=\"pwd\" class=\"form-label\"&gt;Title:&lt;\/label&gt;\n            &lt;input type=\"text\" class=\"form-control\" id=\"title\" placeholder=\"\uc81c\ubaa9\uc744 \uc785\ub825\ud558\uc138\uc694(Please enter the post title)\" name=\"title\" required&gt;\n            &lt;div id=\"errorTitle\"&gt;&lt;\/div&gt;\n        &lt;\/div&gt;<\/mark>\n\n        &lt;div class=\"mb-3\"&gt;\n            &lt;label for=\"pwd\" class=\"form-label\"&gt;Password:&lt;\/label&gt;\n            &lt;input type=\"password\" class=\"form-control\" id=\"pwd\" placeholder=\"Enter password\" name=\"pswd\" required&gt;\n            &lt;div id=\"errorPwd\"&gt;&lt;\/div&gt;\n        &lt;\/div&gt;        \n\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">        &lt;div class=\"mb-3\"&gt;\n            &lt;label for=\"comment\" class=\"form-label\"&gt;Comment:&lt;\/label&gt;    \n            &lt;textarea id=\"comment\"name=\"comment\" rows=\"5\" cols=\"40\" class=\"form-control\"&gt;&lt;\/textarea&gt;\n            &lt;div id=\"errorComment\"&gt;&lt;\/div&gt;\n        &lt;\/div&gt;<\/mark>\n\n        &lt;div class=\"mb-3\"&gt;\n            &lt;div class=\"form-check mb-3\"&gt;\n            &lt;label class=\"form-check-label\"&gt;Remember me&lt;\/label&gt;\n            &lt;input class=\"form-check-input\" type=\"checkbox\" name=\"remember\"&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n            &lt;button type=\"button\" class=\"btn btn-primary\" onClick=\"frmSubmit();\"&gt;Submit&lt;\/button&gt;\n        &lt;\/form&gt;\n    &lt;\/div&gt;    \n    &lt;\/body&gt;\n&lt;\/html&gt;    <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>form_action5.php\n\n&lt;?php  \nif($_SERVER&#91;'REQUEST_METHOD'] == \"POST\"){\n\n   $f_name = $_POST&#91;'name'];\n   $f_email = $_POST&#91;'email'];\n   $f_title = $_POST&#91;'title'];\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">   $f_website = $_POST&#91;'website'];\n   $f_comment = $_POST&#91;'comment'];<\/mark>\n   $f_pwd = $_POST&#91;'pswd'];\n}\n\necho \"REQUEST_METHOD:\".$_SERVER&#91;'REQUEST_METHOD'].\"&lt;br&gt;\";\necho \"\uc774\ub984(NAME):\".$f_name.\"&lt;br&gt;\";\necho \"\uc774\uba54\uc77c(EMAIL):\".$f_email.\"&lt;br&gt;\";\necho \"\uc81c\ubaa9(TITLE):\".$f_title.\"&lt;br&gt;\";\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">echo \"\uc6f9\uc0ac\uc774\ud2b8(WEBSITE):\".$f_website.\"&lt;br&gt;\";\necho \"\uae00 \ub0b4\uc6a9(CONTENT):\".$f_comment.\"&lt;br&gt;\";<\/mark>\necho \"\ud328\uc2a4\uc6cc\ub4dc(PASSWORD):\".$f_pwd;\n\n?&gt;<\/code><\/pre>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/www.facebook.com\/plugins\/video.php?height=314&#038;href=https%3A%2F%2Fwww.facebook.com%2Fgideonslife01%2Fvideos%2F683136090541287%2F&#038;show_text=false&#038;width=560&#038;t=0\" width=\"560\" height=\"314\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowfullscreen=\"true\" allow=\"autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share\" allowFullScreen=\"true\"><\/iframe>\n","protected":false},"excerpt":{"rendered":"<p>\uceec\ub7ec\ub85c \uac15\uc870\ub41c \ubd80\ubd84\uc740 \ubaa8\ub450 \uc0c8\ub85c \ucd94\uac00\ub41c \ucf54\ub4dc \uc785\ub2c8\ub2e4.\ub179\uc0c9\uc740 \uc0c8\ub86d\uac8c \ucd94\uac00\ub41c \ubd80\ubd84\uc774\ub098 \uae30\uc874 \ubd80\ubd84\uacfc \uc720\uc0ac\ud55c \ubd80\ubd84\uc785\ub2c8\ub2e4.\ub178\ub780\uc0c9 \ubd80\ubd84\uc740 URL\uc744 \ud655\uc778\ud558\uae30 \uc704\ud55c \ubd80\ubd84\uc785\ub2c8\ub2e4.\uc624\ub80c\uc9c0\uc0c9 \ubd80\ubd84\uc740 URL\uc744 \uccb4\ud06c\ud558\uae30 \uc704\ud55c \uc815\uaddc\ud45c\ud604\uc2dd \ubd80\ubd84\uc785\ub2c8\ub2e4.URL\ud655\uc778 \ubd80\ubd84\ub3c4 \uc774\uba54\uc77c \ud655\uc778 \ubd80\ubd84\uacfc \ud06c\uac8c \ub2e4\ub974\uc9c0 \uc54a\uc9c0\ub9cc \ud544\uc218 \ud56d\ubaa9\uc774 \uc544\ub2c8\uae30 \ub54c\ubb38\uc5d0 \uacf5\ubc31\ud655\uc778\uc740 \ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. All parts highlighted in color are newly added codes.The Green part is a newly added [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-469","post","type-post","status-publish","format-standard","hentry","category-php","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=469"}],"version-history":[{"count":6,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/469\/revisions"}],"predecessor-version":[{"id":476,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/469\/revisions\/476"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}