⊗ppPmRdFV 412 of 447 menu

Redirect on Form Validation in PHP

Now imagine that you need to perform form validation. If the validation is passed successfully, then we will save the form to the database and display a success message. Otherwise, we need to display a failure message. Let's implement it:

<?php session_start(); if (!empty($_POST)) { if (form validation) { // save to the database $_SESSION['flash'] = 'form saved successfully'; header('Location: form.php'); die(); } else { $_SESSION['flash'] = 'form validation failed'; } } if (isset($_SESSION['flash'])) { echo $_SESSION['flash']; unset($_SESSION['flash']); } ?>

Modify the previous task so that form validation is performed. Make it so that the form data does not disappear after submission.

Modify the previous task so that the form data does not disappear after 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