⊗ppPmFmVR 301 of 447 menu

Saving Form Values After Submission in PHP

Suppose we have a form that submits to the current page:

<form action="" method="GET"> <input name="test"> <input type="submit"> </form>

Let's make it so that after submission the entered data does not disappear from our input:

<form action="" method="GET"> <input name="test" value="<?php echo $_GET['test'] ?>"> <input type="submit"> </form>

This approach, however, is not perfect - on the first visit to the page, PHP will throw an error because $_GET['test'] does not exist.

To solve the problem, let's add a condition:

<form action="" method="GET"> <input name="test" value="<?php if (isset($_GET['test'])) echo $_GET['test'] ?>" > <input type="submit"> </form>

Using a form, ask the user for their city and country. After submitting the form, display the entered data on the screen. Make sure the entered data does not disappear from the inputs after form submission.

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