{"id":157,"date":"2021-06-04T13:04:32","date_gmt":"2021-06-04T12:04:32","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/?page_id=157"},"modified":"2021-06-07T21:34:50","modified_gmt":"2021-06-07T20:34:50","slug":"forms","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/html\/forms\/","title":{"rendered":"Forms"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-197\" src=\"https:\/\/glow-prod-sh.s3.eu-west-1.amazonaws.com\/sh\/public\/ahscomputinghtml\/uploads\/sites\/3275\/2021\/06\/05211153\/sqa-h-150x150.png?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&#038;X-Amz-Security-Token=IQoJb3JpZ2luX2VjEE4aCWV1LXdlc3QtMSJHMEUCIQCy5U9KCQDkAOmSk7qY37d3TpDt6li8ykZzbn26TPTNSgIgDkzWMZ%2FHNX0mZgmwVdpzpVlwJdD99DO%2BylgwFO7NnlUquQUIFxAFGgwyNzM1NzAxOTU0MzMiDBQlR562JauUYVir8iqWBcvtq3riHVv6VN7CwUDJN%2BU%2Bi%2BNPbkOILqlwaeyq8fvgJwkAYCT1zc8UF5BSHIJQKMSjxa0ye2IWM4xlc3eyw%2Bduvkn6cRaruuQZl8EcAIU4TJoBHhTl%2Bvj2NhGXfNrk4icVCma%2BQgNxUn9cBEekSODjSCcGNW5g9Z9Ef%2F75n9K3srlBSEJ%2FWP7taAsFh7YyFlvzzS0VuE0W%2FzBeCwAKdnRJ7ZY2Njx6IaGVsLZMeBs87goUDMl%2BufTMd%2Fu2ByXc9ng54uZPck1dq125PpcXkhf%2BCLI%2F12Lo2av%2BQ%2B34wowftPQqI5kVQwvXpo3tknZeE1YqXeua6BR5j7FFtIWZZPunfsJHoRn13y2DFbLsOD1wM64T69VhEshS3n1FOLmEJiNs2XRuaunP5q%2BoitboT1V6iHplUsIgRm7i6bS%2FZMuiCC1ITpeQCMh7Hwb4FZuB%2FAqpKmgpmrOnw00SvRdF9SYqL%2B0FydtF%2BAEGakI9ffUwCNM%2F0hXBU2JTCP9VBOhTGy4nGz6%2BhIfp2KHoVzh4h8bJWDfhiW1lteHbnJh%2FvN%2BlVzDj5l9cdtGVWcKXrILUeHbPp1%2Fis8BENsimxMbWRX9VVQ1aKyT1W3FiooqYNMx3l0YP2oogSyey4NbawAFayAxPElUokLnVcDnwI29dIfGQ4MSeUwUvDflWNQUC4yczcsUVPtAyrBk%2B%2B3YvZb2LunFOdloOMMOagMM225fkR5F6gSS6bn8VvhWVtSg2bIwO2fxCQ0T1gTaXTKbAl%2BzHuUi9O1yo2b6M6NyAKecE4aUS2iJ3lYMC0i1wFlpAEdykUrH2AzfZhqa6qtmcWBcChsnToqAKyjwp1xqK9fyu7A8vztH4Ql30IHj%2FtVgm3SpXIqu8j0d7MLv%2Fls8GOrEBRDhnNJXU5%2B0WkBlRquweKtVrE0xG0YRZ8qhKDafjJdee2j%2FfKJD6cn1tkxpdIlrgi%2FQ75PghA3JY%2B6SB4n6WnLjBo37ouz8eW0fy3wna%2BTSdKFV2Dm%2Fphd8%2BpzWMEEMwCe4q%2FtzehlGGRTrpcJi93NvMg4p2DhYjT7eA631HEqxPLrC5mo2UtvGRNo2LfrXQbLk8YUNqW0AdMA5Zb2MJ94bAzzpBpewcP0jkmcotH0XO&#038;X-Amz-Algorithm=AWS4-HMAC-SHA256&#038;X-Amz-Credential=ASIAT7MQN47UTEEPTRSC%2F20260420%2Feu-west-1%2Fs3%2Faws4_request&#038;X-Amz-Date=20260420T064418Z&#038;X-Amz-SignedHeaders=host&#038;X-Amz-Expires=900&#038;X-Amz-Signature=960978ec7955b2500620eb11b947613ef4a611a92aa61da23d6b94687e566f6b\" alt=\"\" width=\"100\" height=\"97\" \/><a href=\"https:\/\/www.w3schools.com\/html\/html_forms.asp\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"image-59 alignright\" src=\"https:\/\/glow-prod-sh.s3.eu-west-1.amazonaws.com\/sh\/public\/ahscomputinghtml\/uploads\/sites\/3275\/2021\/06\/03210120\/w3schools-150x150.png?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&#038;X-Amz-Security-Token=IQoJb3JpZ2luX2VjEE4aCWV1LXdlc3QtMSJHMEUCIQCy5U9KCQDkAOmSk7qY37d3TpDt6li8ykZzbn26TPTNSgIgDkzWMZ%2FHNX0mZgmwVdpzpVlwJdD99DO%2BylgwFO7NnlUquQUIFxAFGgwyNzM1NzAxOTU0MzMiDBQlR562JauUYVir8iqWBcvtq3riHVv6VN7CwUDJN%2BU%2Bi%2BNPbkOILqlwaeyq8fvgJwkAYCT1zc8UF5BSHIJQKMSjxa0ye2IWM4xlc3eyw%2Bduvkn6cRaruuQZl8EcAIU4TJoBHhTl%2Bvj2NhGXfNrk4icVCma%2BQgNxUn9cBEekSODjSCcGNW5g9Z9Ef%2F75n9K3srlBSEJ%2FWP7taAsFh7YyFlvzzS0VuE0W%2FzBeCwAKdnRJ7ZY2Njx6IaGVsLZMeBs87goUDMl%2BufTMd%2Fu2ByXc9ng54uZPck1dq125PpcXkhf%2BCLI%2F12Lo2av%2BQ%2B34wowftPQqI5kVQwvXpo3tknZeE1YqXeua6BR5j7FFtIWZZPunfsJHoRn13y2DFbLsOD1wM64T69VhEshS3n1FOLmEJiNs2XRuaunP5q%2BoitboT1V6iHplUsIgRm7i6bS%2FZMuiCC1ITpeQCMh7Hwb4FZuB%2FAqpKmgpmrOnw00SvRdF9SYqL%2B0FydtF%2BAEGakI9ffUwCNM%2F0hXBU2JTCP9VBOhTGy4nGz6%2BhIfp2KHoVzh4h8bJWDfhiW1lteHbnJh%2FvN%2BlVzDj5l9cdtGVWcKXrILUeHbPp1%2Fis8BENsimxMbWRX9VVQ1aKyT1W3FiooqYNMx3l0YP2oogSyey4NbawAFayAxPElUokLnVcDnwI29dIfGQ4MSeUwUvDflWNQUC4yczcsUVPtAyrBk%2B%2B3YvZb2LunFOdloOMMOagMM225fkR5F6gSS6bn8VvhWVtSg2bIwO2fxCQ0T1gTaXTKbAl%2BzHuUi9O1yo2b6M6NyAKecE4aUS2iJ3lYMC0i1wFlpAEdykUrH2AzfZhqa6qtmcWBcChsnToqAKyjwp1xqK9fyu7A8vztH4Ql30IHj%2FtVgm3SpXIqu8j0d7MLv%2Fls8GOrEBRDhnNJXU5%2B0WkBlRquweKtVrE0xG0YRZ8qhKDafjJdee2j%2FfKJD6cn1tkxpdIlrgi%2FQ75PghA3JY%2B6SB4n6WnLjBo37ouz8eW0fy3wna%2BTSdKFV2Dm%2Fphd8%2BpzWMEEMwCe4q%2FtzehlGGRTrpcJi93NvMg4p2DhYjT7eA631HEqxPLrC5mo2UtvGRNo2LfrXQbLk8YUNqW0AdMA5Zb2MJ94bAzzpBpewcP0jkmcotH0XO&#038;X-Amz-Algorithm=AWS4-HMAC-SHA256&#038;X-Amz-Credential=ASIAT7MQN47UTEEPTRSC%2F20260420%2Feu-west-1%2Fs3%2Faws4_request&#038;X-Amz-Date=20260420T064418Z&#038;X-Amz-SignedHeaders=host&#038;X-Amz-Expires=900&#038;X-Amz-Signature=32d5304116be2e72533bce98fff71905c2c093206bae87363e81909a81b24131\" alt=\"\" width=\"50\" height=\"47\" \/><\/a>Forms are used to collect information from the user, which is then sent to the web server for processing.<\/p>\n<p>This usually involves the use of PHP to create SQLs commands to access a database. This is covered in the Advanced Higher Computing Science course. At Higher level you need to know how to create a form, but do not need to process the data.<\/p>\n<p>A form includes several elements &#8211; both HTML and from specific. Any element that collects data must have a unique name:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;form action=&quot;xyz.php&quot; method=&quot;get&quot;&gt;\r\n    First name: &lt;input type=&quot;text&quot; name=&quot;firstname&quot;&gt;&lt;br&gt;\r\n    Last name: &lt;input type=&quot;text&quot; name=&quot;lastname&quot;&gt;&lt;br&gt;\r\n    &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<h1>Form Header<\/h1>\n<p>A &lt;form&gt; tag schould have an action and a method. You do not need to use these for the Higher level course, but they can be used to help test your forms.<\/p>\n<ul>\n<li>action=&#8221;xyz.php&#8221;<br \/>\nThis is the name of the program which is to process the form data. This will fail, as there isn&#8217;t an xyz.php to process the data. However, if you look at the address bar you will be able to see the data values sent.<\/li>\n<li>method=&#8221;get&#8221;<br \/>\nThe &#8220;get&#8221; method includes data as part of the page address, and can be viewed in the address bar. This is suitable for testing, and for bookmarking results. However, the data is recorded in web histories, which could be accessed without permission.<br \/>\nThe &#8220;post&#8221; method does not include data as part of the age address, so is the better option for confidential data.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h1><a href=\"https:\/\/www.w3schools.com\/html\/html_form_input_types.asp\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"image-59 alignright\" src=\"https:\/\/glow-prod-sh.s3.eu-west-1.amazonaws.com\/sh\/public\/ahscomputinghtml\/uploads\/sites\/3275\/2021\/06\/03210120\/w3schools-150x150.png?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&#038;X-Amz-Security-Token=IQoJb3JpZ2luX2VjEE4aCWV1LXdlc3QtMSJHMEUCIQCy5U9KCQDkAOmSk7qY37d3TpDt6li8ykZzbn26TPTNSgIgDkzWMZ%2FHNX0mZgmwVdpzpVlwJdD99DO%2BylgwFO7NnlUquQUIFxAFGgwyNzM1NzAxOTU0MzMiDBQlR562JauUYVir8iqWBcvtq3riHVv6VN7CwUDJN%2BU%2Bi%2BNPbkOILqlwaeyq8fvgJwkAYCT1zc8UF5BSHIJQKMSjxa0ye2IWM4xlc3eyw%2Bduvkn6cRaruuQZl8EcAIU4TJoBHhTl%2Bvj2NhGXfNrk4icVCma%2BQgNxUn9cBEekSODjSCcGNW5g9Z9Ef%2F75n9K3srlBSEJ%2FWP7taAsFh7YyFlvzzS0VuE0W%2FzBeCwAKdnRJ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-Date=20260420T064418Z&#038;X-Amz-SignedHeaders=host&#038;X-Amz-Expires=900&#038;X-Amz-Signature=32d5304116be2e72533bce98fff71905c2c093206bae87363e81909a81b24131\" alt=\"\" width=\"50\" height=\"47\" \/><\/a>Form Elements<\/h1>\n<p>There are many input types, the following are the ones required for Higher Computing.<\/p>\n<h2>input type=&#8221;text&#8221;<\/h2>\n<p>Used to collect textual data in a single-line text box.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n   Username: &lt;input type=&quot;text&quot; name=&quot;userid&quot;&gt;\r\n<\/pre>\n<p>Optional parameters:<\/p>\n<ul>\n<li>value=&#8221;Enter name&#8221;<br \/>\nDefault value shown in the input box<\/li>\n<li>size=&#8221;30&#8243;<br \/>\nset the width of the box, in characters<\/li>\n<li>maxlength = &#8220;15&#8221;<br \/>\nlimit number of characters allowed (length check)<\/li>\n<li>required<br \/>\npresence check<\/li>\n<\/ul>\n<h2>input type=&#8221;number&#8221;<\/h2>\n<p>Used to collect numeric data in a single-line text box.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nRating (1-5): &lt;input type=&quot;number&quot; name=&quot;rating&quot;&gt;\r\n<\/pre>\n<p>Optional parameters:<\/p>\n<ul>\n<li>value=&#8221;1&#8243;<br \/>\nDefault value shown in the input box<\/li>\n<li>min=&#8221;1&#8243; max=&#8221;5&#8243;<br \/>\nset minimum and\/or maximum values allowed (range check)<\/li>\n<li>required<br \/>\npresence check<\/li>\n<\/ul>\n<h2>input type=&#8221;textarea&#8221;<\/h2>\n<p>Used to collect textual data in a multi-line text box.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nComments:\r\n&lt;input type=&quot;textara&quot; name=&quot;comments&quot; rows=&quot;3&quot; cols=&quot;50&quot;&gt;\r\n<\/pre>\n<p>Required parameters:<\/p>\n<ul>\n<li>rows=&#8221;3&#8243;<br \/>\nheight of box in lines of text<\/li>\n<li>cols= &#8220;50&#8221;<br \/>\nwidth of box in characters<\/li>\n<\/ul>\n<p>Optional parameters:<\/p>\n<ul>\n<li>value=&#8221;Enter your review&#8221;<br \/>\nDefault value shown in the input box<\/li>\n<li>maxlength = &#8220;100&#8221;<br \/>\nlimit number of characters allowed (length check)<\/li>\n<li>required<br \/>\npresence check<\/li>\n<\/ul>\n<h2>input type=&#8221;radio&#8221;<\/h2>\n<p>Radio buttons several options, of which only one can be chosen.<\/p>\n<p>All buttons in a group have the same name.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nChoose your age:&lt;br&gt;\r\n&lt;input type=&quot;radio&quot; name=&quot;age&quot; value=&quot;12 to 14&quot;&gt;12-14\r\n&lt;input type=&quot;radio&quot; name=&quot;age&quot; value=&quot;15 or 16&quot;&gt;15,16\r\n&lt;input type=&quot;radio&quot; name=&quot;age&quot; value=&quot;17 or over&quot;&gt;over 16\r\n<\/pre>\n<p>Required parameters:<\/p>\n<ul>\n<li>value=&#8221;12 to 15&#8243;<br \/>\nthe value to be submitted to the web server<\/li>\n<\/ul>\n<p>Optional parameters<\/p>\n<ul>\n<li>checked<br \/>\ndefault selection<\/li>\n<\/ul>\n<h2>input type=&#8221;submit&#8221;<\/h2>\n<p>Display a button to submit the form data to the web server.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;\r\n<\/pre>\n<p>Optional parameters:<\/p>\n<ul>\n<li>value=&#8221;Submit&#8221;<br \/>\nText to display on the button<\/li>\n<\/ul>\n<h2>select<\/h2>\n<p>Choose option(s) from a drop-down list.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;select name=&quot;play&quot; size=&quot;3&quot; multiple&gt;\r\n    &lt;option value=&quot;hamlet&quot;&gt;Hamlet&lt;\/option&gt;\r\n    &lt;option value=&quot;godo&quot;&gt;Waiting for Godo&lt;\/option&gt;\r\n    &lt;option value=&quot;brothers&quot;&gt;Blood Brothers&lt;\/option&gt;\r\n    &lt;option value=&quot;curious&quot;&gt;Curious Incident&lt;\/option&gt;\r\n&lt;\/select&gt;\r\n<\/pre>\n<p>Required parameters:<\/p>\n<ul>\n<li>value=&#8221;hamlet&#8221;<br \/>\nthe value to be submitted to the web server<\/li>\n<\/ul>\n<p>Optional parameters<\/p>\n<ul>\n<li>size=&#8221;3&#8243;<br \/>\nthe height\/number of options displayed. A scroll bar will appear if the size is less than the number of options<\/li>\n<li>multiple<br \/>\nallow several options to be selected<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Forms are used to collect information from the user, which is then sent to the web server for processing. This usually involves the use of PHP to create SQLs commands to access a database. This is covered in the Advanced Higher Computing Science course. At Higher level you need to know how to create a form, but do not need to process the data. A form includes several elements &#8211;<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/html\/forms\/\">Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":16,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-157","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":18,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/157\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/157\/revisions\/160"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/16"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/media?parent=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}