⊗ppPmFmDGEG 297 of 447 menu

Retrieving Form Data Using the GET Method in PHP

Let's look at an example. Let the file form.php contain a form that is submitted using the GET method to the page result.php:

<form action="/en/result.php" method="GET"> <input name="test1"> <input name="test2"> <input type="submit"> </form>

If we enter some data into our form in the browser and press the button, the form will be submitted to the page result.php:

<?php var_dump($_GET); // array with keys test1 and test2 var_dump($_POST); // empty array var_dump($_REQUEST); // array with keys test1 and test2 ?>

You can also display the contents of a specific input:

<?php echo $_GET['test1']; ?>

You can also take the contents of both the first and the second inputs, combine them into a string, and display it:

<?php echo $_GET['test1'] . $_GET['test2']; ?>

Create a form with three inputs. Let numbers be entered into these inputs. After submitting the form, display the sum of these numbers.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline