Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I'm understanding you correctly, you want to be able to propagate the <code>$_GET</code> value even through a <code>POST</code> method. You can do this by appending the query string to the action attribute of the second <code>POST</code> form:</p> <pre><code>&lt;form action="&lt;?php echo htmlentities($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] );?&gt;" name="atualizarDominio" method="post"&gt; </code></pre> <p>EDIT: Ok, I think I understand a bit better. </p> <p>In the first case, (with the second form action as <code>$_SERVER['PHP_SELF']</code>), you are forcing the form to post the data to the page without all the added <code>$_GET</code> data (if you look at the URL, the <code>$_GET</code> data is appended to the file name after the <code>?</code>), so when you look for <code>$_GET['infoDominio']</code>, it doesn't exist any more, and therefore <code>$nomeDominio</code> is still set to an empty string. When you send the <code>POST</code> form, the <code>$_POST['atualizarDominio']</code> IS set, and you get the <code>I'm posting</code> message, but with no value set in <code>$nomeDominio</code>.</p> <p>Now when you change the action of the second form to <code>""</code>, you are telling the browser to send the user to the same page you were just on, which includes all the <code>$_GET</code> data in the URL (check it - you find the <code>?nomeDominio=whatever&amp;infoDominio=</code> in the address bar still). When you submit the second form after having submitted the first form, all the <code>$_GET</code> data is propagated, and so <code>$_GET['infoDominio']</code> is set, <code>$nomeDominio</code> is assigned whatever value you put in the first form, and thus shows up in the page after submitting the second form.</p> <p>The fact that the form name and the submit button name are the same shouldn't affect it.</p> <p>If I'm still misunderstanding what you're asking, please let me know. Otherwise I hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload