title: How does a PHP page retrieve form data?
body: <p>I am new to PHP and am taking the PHP course on <a href="https://en.wikipedia.org/wiki/W3Schools" rel="nofollow noreferrer">W3Schools</a>. In the form handling part of the course, I read that there are two methods of handling form data: <a href="https://en.wikipedia.org/wiki/POST_%28HTTP%29" rel="nofollow noreferrer">POST</a> and <a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods" rel="nofollow noreferrer">GET</a>. I understand that depending on the method used, a superglobal variable is created which stores the data as key-value pairs. And at the destination page, the data is retrieved from this variable (using <code>$_POST[&quot;key&quot;]</code> or <code>$_GET[&quot;key&quot;]</code>).</p>
  <p>But my question is: Where is the superglobal variable (<code>$_POST</code> or <code>$_GET</code>) stored? If it is on that same page on which the form exists, how can it be accessed by another destination page specified in the <code>action</code> attribute of the <code>form</code> tag?</p>
  <p>Is it that the same set of these superglobal variables are accessible by all the pages on the server (contrary to my present belief that <strong>each</strong> page has its own set of those)?</p>
  <p>The code below should make my question more clear:</p>
  <h3>File <em>index.php</em></h3>
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;form action=&quot;welcome.php&quot; method=&quot;post&quot;&gt;
      Name: &lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;&lt;br&gt;
      E-mail: &lt;input type=&quot;text&quot; name=&quot;email&quot;&gt;&lt;br&gt;
      &lt;input type=&quot;submit&quot;&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <h3>File <em>welcome.php</em></h3>
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
      Welcome &lt;?php echo $_POST[&quot;name&quot;]; ?&gt;&lt;br&gt;
      Your email address is: &lt;?php echo $_POST[&quot;email&quot;]; ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>W3Schools explains as follows:</p>
  <blockquote>
  <p>When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named &quot;welcome.php&quot;. The form data is sent with the HTTP POST method.
  To display the submitted data you could simply echo all the variables.</p>
  </blockquote>
  <p>How do the variables <code>$_POST[&quot;name&quot;]</code> and <code>$_POST[&quot;email&quot;]</code> reach <em>welcome.php</em>?</p>