{"id":1131,"date":"2012-01-26T15:04:28","date_gmt":"2012-01-26T15:04:28","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/01\/26\/create-html-form\/"},"modified":"2023-10-17T13:49:18","modified_gmt":"2023-10-17T17:49:18","slug":"create-html-form","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/","title":{"rendered":"Creating a Simple HTML Form to Get User Comments"},"content":{"rendered":"<p>In this tutorial, we&#8217;re showing you how to setup a <strong>HTML form<\/strong> that allows a user to enter comments. We will achieve this by interacting with a MySQL Database using PHP on <a href=\"https:\/\/www.inmotionhosting.com\/cpanel-hosting\">cPanel Hosting<\/a>. We&#8217;re creating a simple 2 page website that allows users to post <strong>comments<\/strong> on either page, and then shows all comments that have been posted.<\/p>\n<p>Be sure to check out our previous article where we <a href=\"\/support\/website\/database-setup\/\">created a database<\/a> and setup a table to hold those comments.<\/p>\n<h2>A Quick Introduction to HTML Forms<\/h2>\n<h3>Gathering the Form Data<\/h3>\n<p>An HTML form allows a user to type data into a website, and then it submits the data to another page for processing. For example, if you fill out a comment on a website and hit submit, everything that you typed in is submitted to a script on the server that writes your comment to a database.<\/p>\n<p>HTML forms can handle quite a few different forms of input. For example, they can handle:<\/p>\n<ul>\n<li><strong>Text Boxes:<\/strong><br \/>\n<input type=\"text\" value=\"Enter some text here\" \/><\/li>\n<li><strong>Radio Buttons<\/strong><br \/>\n<input id=\"textradio\" name=\"testradio\" type=\"radio\" value=\"option1\" \/> Option 1<br \/>\n<input id=\"textradio\" name=\"testradio\" type=\"radio\" value=\"option2\" \/> Option 2<\/li>\n<li><strong>Checkboxes<\/strong><br \/>\n<input type=\"checkbox\" value=\"selection1\" \/> Selection 1<br \/>\n<input type=\"checkbox\" value=\"selection2\" \/> Selection 2<\/li>\n<li><strong>&#8230; and more!<\/strong><\/li>\n<\/ul>\n<h3>Submitting the Form Data<\/h3>\n<p>After the user has filled in the above data and clicks a submit button, it will send all of their data to another script for processing. It can either send the data back to the same page for processing, or it can send it to a completely different script to handle the processing.<\/p>\n<p>When the data is passed to a script for processing, it can be passed using either GET or POST. When using GET, all the data is passed in the url, such as:<br \/>\n<strong>GET<\/strong> <strong>domain.com\/page.php?name=brad&amp;email=brad@domain.com<\/strong><\/p>\n<p>As you can see, my name and email address is passed in the URL. If you use POST (instead of get), the URL will simple read:<\/p>\n<p><strong>POST<\/strong> <strong>domain.com\/page.php<\/strong><br \/>\n&#8230; and my name and email address will be passed behind the scenes.<\/p>\n<h2>Our Example Contact Form<\/h2>\n<p>Because our comments form is going to be relatively simple, we will be using text boxes for most of the input. Below is our contact form and what the contact form will look like:<\/p>\n<div style=\"padding: 2px; border: 1px solid #000;\">\n<form method=\"post\">NAME: <input id=\"name\" name=\"name\" type=\"text\" \/> Email: <input id=\"email\" name=\"email\" type=\"text\" \/> Website: <input id=\"website\" name=\"website\" type=\"text\" \/> Comment: <textarea id=\"comment\" name=\"comment\"><\/textarea> <input id=\"articleid\" name=\"articleid\" type=\"hidden\" value=\"&lt;? echo $_GET[&quot;id&quot;]; ?&gt;\" \/> <input type=\"submit\" value=\"Submit\" \/><\/form>\n<p>NAME: <input id=\"name\" name=\"name\" type=\"text\" \/><br \/>\nEmail: <input id=\"email\" name=\"email\" type=\"text\" \/><br \/>\nWebsite: <input id=\"website\" name=\"website\" type=\"text\" \/><br \/>\nComment:<br \/>\n<textarea id=\"comment\" name=\"comment\"><\/textarea><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we&#8217;re showing you how to setup a HTML form that allows a user to enter comments. We will achieve this by interacting with a MySQL Database using PHP on cPanel Hosting. We&#8217;re creating a simple 2 page website that allows users to post comments on either page, and then shows all comments<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\"> Read More ><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4288],"tags":[],"class_list":["post-1131","post","type-post","status-publish","format-standard","hentry","category-website"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creating a Simple HTML Form to Get User Comments<\/title>\n<meta name=\"description\" content=\"Make your website interactive by creating a simple HTML form. Learn PHP and gather important from your users.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating a Simple HTML Form to Get User Comments\" \/>\n<meta property=\"og:description\" content=\"Make your website interactive by creating a simple HTML form. Learn PHP and gather important from your users.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2012-01-26T15:04:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-17T17:49:18+00:00\" \/>\n<meta name=\"author\" content=\"Brad Markle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brad Markle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\"},\"author\":{\"name\":\"Brad Markle\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\"},\"headline\":\"Creating a Simple HTML Form to Get User Comments\",\"datePublished\":\"2012-01-26T15:04:28+00:00\",\"dateModified\":\"2023-10-17T17:49:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\"},\"wordCount\":374,\"commentCount\":221,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Website\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\",\"name\":\"Creating a Simple HTML Form to Get User Comments\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2012-01-26T15:04:28+00:00\",\"dateModified\":\"2023-10-17T17:49:18+00:00\",\"description\":\"Make your website interactive by creating a simple HTML form. Learn PHP and gather important from your users.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating a Simple HTML Form to Get User Comments\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\",\"name\":\"Brad Markle\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating a Simple HTML Form to Get User Comments","description":"Make your website interactive by creating a simple HTML form. Learn PHP and gather important from your users.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/","og_locale":"en_US","og_type":"article","og_title":"Creating a Simple HTML Form to Get User Comments","og_description":"Make your website interactive by creating a simple HTML form. Learn PHP and gather important from your users.","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2012-01-26T15:04:28+00:00","article_modified_time":"2023-10-17T17:49:18+00:00","author":"Brad Markle","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Brad Markle","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/"},"author":{"name":"Brad Markle","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf"},"headline":"Creating a Simple HTML Form to Get User Comments","datePublished":"2012-01-26T15:04:28+00:00","dateModified":"2023-10-17T17:49:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/"},"wordCount":374,"commentCount":221,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Website"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/","name":"Creating a Simple HTML Form to Get User Comments","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2012-01-26T15:04:28+00:00","dateModified":"2023-10-17T17:49:18+00:00","description":"Make your website interactive by creating a simple HTML form. Learn PHP and gather important from your users.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/create-html-form\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Creating a Simple HTML Form to Get User Comments"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf","name":"Brad Markle","url":"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4288,"name":"Website","slug":"website","link":"https:\/\/www.inmotionhosting.com\/support\/website\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=1131"}],"version-history":[{"count":7,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1131\/revisions"}],"predecessor-version":[{"id":107238,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1131\/revisions\/107238"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=1131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=1131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=1131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}