HTML Form Get and Post via PHP Priority Tutorial

HTML Form Get and Post via PHP Priority Tutorial

HTML Form Get and Post via PHP Priority Tutorial

As we stated yesterday, with HTML Form Get and Post via PHP Primer Tutorial

An HTML form element allows for method property values of …

  • GET
  • POST

… the latter of which requires a server-side language to glean the HTML form element’s data.

… 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[‘p0′] and a non-blank $_POST[‘p0′] which of these should take precedence as the value subsequently displayed in the HTML form element of our get_post.php (amended PHP)’s live run? 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 … hello, Usy

  • Get takes preference over Post
  • Post takes preference over Get if not null
  • Longer length of Get versus Post determines which

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 …


Object.[ArgumentName]

We’re not saying using Javascript Objects is essential here, but feels like a good fit for this functionality in our books (but not our pamphlettes) eyes.


Previous relevant HTML Form Get and Post via PHP Primer Tutorial is shown below.

HTML Form Get and Post via PHP Primer Tutorial

HTML Form Get and Post via PHP Primer Tutorial

An HTML form element allows for method property values of …

  • GET
  • POST

… the latter of which requires a server-side language to glean the HTML form element’s data.

So we are writing today’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 GET or POST, but our point today is to show you you can write PHP code to process HTML form element data in a GET and/or POST way.

Let’s start by showing you some PHP we got helped out with by this very useful link, thanks, as per …


<?php
foreach ($_POST as $name => $val) {
echo "POST ... " . htmlspecialchars($name . ': ' . $val) . "<br>";
}
foreach ($_GET as $name => $val) {
echo "GET ... " . htmlspecialchars($name . ': ' . $val) . "<br>";
}
?>

… to be “generic” about (ie. nothing about the data’s name is of concern to us … just yet) the specifics of data, but allowing for either method of data transmission to be allowed and processed for.

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 “proof of concept” web application you could call get_post.php for your perusal.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>