{"id":28916,"date":"2017-03-17T03:01:58","date_gmt":"2017-03-16T17:01:58","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=28916"},"modified":"2017-03-17T11:22:34","modified_gmt":"2017-03-17T01:22:34","slug":"html-form-get-and-post-via-php-priority-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-form-get-and-post-via-php-priority-tutorial\/","title":{"rendered":"HTML Form Get and Post via PHP Priority Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML Form Get and Post via PHP Priority Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.gif\" title=\"HTML Form Get and Post via PHP Priority Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">HTML Form Get and Post via PHP Priority Tutorial<\/p><\/div>\n<p>As we stated yesterday, with <a title='HTML Form Get and Post via PHP Primer Tutorial' href='#hfgapvppt'>HTML Form Get and Post via PHP Primer Tutorial<\/a> &#8230;<\/p>\n<blockquote>\n<p>An HTML form element allows for <i>method<\/i> property values of &#8230;<\/p>\n<ul>\n<li>GET<\/li>\n<li>POST<\/li>\n<\/ul>\n<p> &#8230; the latter of which requires a server-side language to glean the HTML form element&#8217;s data.<\/p>\n<\/blockquote>\n<p> &#8230; and then went on to show GET and\/or POST arguments can be coded for in a PHP web application.  That was all well and good, but if there is a non-blank $_GET[&#8216;p0&#8217;] and a non-blank $_POST[&#8216;p0&#8217;] which of these should take precedence as the value subsequently displayed in the HTML form element of our <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.php-GETME\">get_post.php<\/a> (<a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.php-GETME\">amended PHP<\/a>)&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.php\" title='Click picture'>live run<\/a>?  Well, we think that decision should be something that is passed in web application arguments, as well, and we figure some ideas you (hoo?) might like, as a user <font size=1>&#8230; hello, Usy<\/font> &#8230;<\/p>\n<ul>\n<li>Get takes preference over Post<\/li>\n<li>Post takes preference over Get if not null<\/li>\n<li>Longer length of Get versus Post determines which<\/li>\n<\/ul>\n<p>So, having those rules then, we have the information we need to know what order we should use to process arguments, and rules whether to initialize or override Javascript values stored in &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='Javascript Object information from w3schools' href='https:\/\/www.w3schools.com\/js\/js_objects.asp'>Object<\/a>.[ArgumentName]<br \/>\n<\/code><\/p>\n<p>We&#8217;re not saying using Javascript Objects is essential here, but feels like a good fit for this functionality in our <strike title=\"Sheep graziers alert ... repeated joke ... see you on the foul line at 3 ... if I'm not there, start without me\">books <font size=1>(but not our pamphlettes)<\/font><\/strike> eyes.<\/p>\n<hr>\n<p id='hfgapvppt'>Previous relevant <a target=_blank title='HTML Form Get and Post via PHP Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/html-form-get-and-post-via-php-primer-tutorial\/'>HTML Form Get and Post via PHP Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML Form Get and Post via PHP Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.jpg\" title=\"HTML Form Get and Post via PHP Primer Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">HTML Form Get and Post via PHP Primer Tutorial<\/p><\/div>\n<p>An HTML form element allows for <i>method<\/i> property values of &#8230;<\/p>\n<ul>\n<li>GET<\/li>\n<li>POST<\/li>\n<\/ul>\n<p> &#8230; the latter of which requires a server-side language to glean the HTML form element&#8217;s data.<\/p>\n<p>So we are writing today&#8217;s tutorial in PHP, and our aim here is to point out that it is within the scope of PHP to be more flexible than to say the HTML form element data is <i>GET<\/i> or <i>POST<\/i>, but our point today is to show you you can write PHP code to process HTML form element data in a <i>GET<\/i> and\/or <i>POST<\/i> way.<\/p>\n<p>Let&#8217;s start by showing you some PHP we got helped out with by <a target=_blank title='PHP Get and Post generic reading' href='http:\/\/stackoverflow.com\/questions\/7163815\/get-name-of-a-post-variable'>this very useful link<\/a>, thanks, as per &#8230;<\/p>\n<p><code><br \/>\n&lt;?php<br \/>\nforeach ($_POST as $name =&gt; $val) {<br \/>\n     echo \"POST ... \" . htmlspecialchars($name . ': ' . $val) . \"&lt;br&gt;\";<br \/>\n}<br \/>\nforeach ($_GET as $name =&gt; $val) {<br \/>\n     echo \"GET ... \" . htmlspecialchars($name . ': ' . $val) . \"&lt;br&gt;\";<br \/>\n}<br \/>\n?&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; to be &#8220;generic&#8221; about (ie. nothing about the data&#8217;s <i>name<\/i> is of concern to us <font size=1>&#8230; just yet<\/font>) the specifics of data, but allowing for either <i>method<\/i> of data transmission to be allowed and processed for.<\/p>\n<p>And so we start on our investigations on this pretty important concept regarding these fairly conventional HTML navigation techniques.  There is a fair bit more to consider, but you can try this &#8220;proof of concept&#8221; <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.php\" title=\"Click picture\">web application<\/a> you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/get_post.php_GETME\">get_post.php<\/a> for your perusal.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d28387' onclick='var dv=document.getElementById(\"d28387\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/form\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d28387' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d28916' onclick='var dv=document.getElementById(\"d28916\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/object\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d28916' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>As we stated yesterday, with HTML Form Get and Post via PHP Primer Tutorial &#8230; An HTML form element allows for method property values of &#8230; GET POST &#8230; the latter of which requires a server-side language to glean the &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-form-get-and-post-via-php-priority-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[452,1533,576,652,830,849,932,970],"class_list":["post-28916","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-form","tag-get","tag-html","tag-javascript","tag-navigation","tag-object","tag-php","tag-post"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/28916"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=28916"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/28916\/revisions"}],"predecessor-version":[{"id":28938,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/28916\/revisions\/28938"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=28916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=28916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=28916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}