I am a curious fellow just beginning to use PHP. I understand the basics of what the $_GET and $_POST superglobals do, and how we can use them to retrieve data after form submission. I also know that since $_GET and $_POST are just associate arrays, we can create our own values in both $_GET and $_POST buy writing statements like $_POST['variable'] = "value".
I am wondering if it is at all possible to send data beyond form data by adding new key/value pairs into $_GET and $_POST. So for example, if I had a form that transferred username/password through Post, would it be possible for me to include further data by just saying $_POST['formtype'] = "house_insurance_form"?
Basically what I'm getting at is trying to physically add your own data to $_POST or $_GET that you could pull from the next page where the form redirects to. In other words, can I send data beyond form data using these superglobals? I know I can do this with $_SESSION, but could I do it through $_POST or $_GET? I haven't been able to accomplish this, and I was just wondering if someone could give me an in-depth explanation of how this might work or how this is not possible. I would really really really appreciate it.
From my understand of PHP $_GET and $_POST, these are only useful in form submissions.
$_GET enables you to get the parms from the URL (the stuff after ?)
$_POST enables you to get the form fields (visible and hidden).
Say you have 2 pages: page 1 is the form and page 2 is the PHP processing. By the time page 1 is submitted, all data is wrapped in the form ($_GET or $_POST). Adding variables to this array during transmission is impossible. Once the array is at the destination (page 2), why need to "add" or "remove" any variables? Such array is for single request, unlike $_SESSION.
Therefore, have all the variables you need in the first page's form.
K. Tsang CEng MBCS PMP PMI-ACP OCPJEA OCPJP
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Two software engineers solve most of the world's problems in one K&R sized book