{"id":16720,"date":"2022-10-21T23:53:34","date_gmt":"2022-10-21T18:23:34","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/"},"modified":"2022-10-21T23:53:34","modified_gmt":"2022-10-21T18:23:34","slug":"solved-how-to-properly-take-input-from-user-to-html-form","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/","title":{"rendered":"[Solved] How to properly take input from user to HTML form?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-43814778\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"43814778\" data-parentid=\"43814371\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>There&#8217;s a lot going wrong here, but I don&#8217;t mean to blame you specifically. Many of the things that make PHP popular, like it&#8217;s long history of support on shared hosting providers and how it&#8217;s easy to pick up and get going, are also a huge liability: There&#8217;s a lot of dangerously old advice out there, and many tutorials are written by people who really do not know what they&#8217;re doing. It is a minefield to navigate, especially if you have never done this sort of thing before.<\/p>\n<p>To side-step all of that you can use a <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codegeekz.com\/best-php-frameworks-for-developers\/\">development framework<\/a> where modern PHP coding practices are on display. The best of these organize the code so that there&#8217;s a very minimal amount of raw PHP code in the web root, that is the files that are accessible to the public. Many have just one stub, <code>index.php<\/code>, which everything is routed through. All the other URLs are, in essence, faked out by routing. There&#8217;s no literal file to back them up. This is good because it decouples URLs from links to files and instead turns them into abstract resources.<\/p>\n<p>This is how they manage to keep the application code from leaking out: The code put in the public web root is extremely minimal by design. If your server ends up misconfigured for whatever reason and starts spewing out <code>.php<\/code> files as raw source there&#8217;s no harm, all they get is the boilerplate <code>index.php<\/code> stub that comes with every application of that type. No credentials, no database configuration information, nothing.<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/laravel.com\/\">Laravel<\/a> is a good example to study, it even includes an <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/laravel.com\/docs\/master\/authentication\">authentication system<\/a> so there&#8217;s no need to code your own. The <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/laravel.com\/docs\/5.4\/database\">database config<\/a> in this case is just a regular PHP file, but other systems use JSON, YAML, or an old-fashioned INI file.<\/p>\n<p>The biggest problem here is the use of string interpolation to compose your queries. If you make a mistake, forget to escape something, you&#8217;ll open up a huge SQL injection hole. From there it&#8217;s possible that someone can inject arbitrary SQL code into your site, and with that, grab the whole database or worse, maybe download the application&#8217;s code as well if the database is running on the same physical machine.<\/p>\n<p>At the absolute least use something like PDO. Even better, use an ORM that encapsulates your database operations in a much easier to use object-oriented wrapper. <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.doctrine-project.org\/\">Doctrine<\/a>, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/propelorm.org\/\">Propel<\/a> and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/laravel.com\/docs\/5.4\/eloquent\">Eloquent<\/a> are all good examples of these. <\/p>\n<p>The most important thing to note is that making a secure site in 2017 is not easy if you&#8217;re building from the ground up using just core PHP. There&#8217;s so many things to consider: CSRF, XSS, SQL injection, password hashing, email verification, password guess rate limiting, caching, database migrations, and a host of other things. Fully understanding and implementing a coherent strategy for any one of those might months. It&#8217;s beyond the scope of a single developer to realistically achieve, though I do encourage you to at least understand them on an academic level, the theory and implications of each.<\/p>\n<p>PHP is lucky it has a lot of very good, well supported frameworks that come in a variety of forms. Find one you really like, learn it well, and use that for your projects. You&#8217;ll be able to focus on writing code that makes your application unique instead of wasting a good chunk of that time badly re-implementing the wheel.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">4<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How to properly take input from user to HTML form? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] There&#8217;s a lot going wrong here, but I don&#8217;t mean to blame you specifically. Many of the things that make PHP popular, like it&#8217;s long history of support on shared hosting providers and how it&#8217;s easy to pick up and get going, are also a huge liability: There&#8217;s a lot of dangerously old advice &#8230; <a title=\"[Solved] How to properly take input from user to HTML form?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\" aria-label=\"More on [Solved] How to properly take input from user to HTML form?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[346,340,339],"class_list":["post-16720","post","type-post","status-publish","format-standard","hentry","category-solved","tag-html","tag-mysql","tag-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How to properly take input from user to HTML form? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How to properly take input from user to HTML form? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] There&#8217;s a lot going wrong here, but I don&#8217;t mean to blame you specifically. Many of the things that make PHP popular, like it&#8217;s long history of support on shared hosting providers and how it&#8217;s easy to pick up and get going, are also a huge liability: There&#8217;s a lot of dangerously old advice ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-21T18:23:34+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How to properly take input from user to HTML form?\",\"datePublished\":\"2022-10-21T18:23:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\"},\"wordCount\":605,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"html\",\"mysql\",\"php\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\",\"name\":\"[Solved] How to properly take input from user to HTML form? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-10-21T18:23:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How to properly take input from user to HTML form?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How to properly take input from user to HTML form? - JassWeb","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:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How to properly take input from user to HTML form? - JassWeb","og_description":"[ad_1] There&#8217;s a lot going wrong here, but I don&#8217;t mean to blame you specifically. Many of the things that make PHP popular, like it&#8217;s long history of support on shared hosting providers and how it&#8217;s easy to pick up and get going, are also a huge liability: There&#8217;s a lot of dangerously old advice ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/","og_site_name":"JassWeb","article_published_time":"2022-10-21T18:23:34+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How to properly take input from user to HTML form?","datePublished":"2022-10-21T18:23:34+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/"},"wordCount":605,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["html","mysql","php"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/","name":"[Solved] How to properly take input from user to HTML form? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-10-21T18:23:34+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-properly-take-input-from-user-to-html-form\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How to properly take input from user to HTML form?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/16720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=16720"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/16720\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=16720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=16720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=16720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}