The foreach loop is creating an hidden form field for each element found in the $_POST array. The onload call is submitting the form into which those form fields are inserted within the HTML <form> section. Why you would want to do it that way is unknown to me.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Well, the reason I want to do the "submitting" form is because to check if there are values been sending into the form - I saw some people use that method for checking purposed? Is that not correct?
I don't know, but it seems to me that as soon as the page finished loading it would then submit the form, which would take you to the form-handler page that is that form field's action, and without the user ever doing anything, so it seems like wasted HTTP traffic between the server and browser. Normally, if the validation is successful, I would have just run the processing code at that point, which you could probably do simply by including your form-handler script at that point instead of going through this extra stuff:
PHP Code:
<?php // do validation stuff, then do... if($validation_is_ok) { // change to however you confirm inputs are OK require 'confirmCreate.php'; exit; } // rest of page, without that foreach loop, the onload stuff or the hidden form ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head>
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks