Skip to content
Advertisement

Can’t figure out how to keep form data on refresh/failed form submission

I need to make a form that keeps the data within its fields if the page were to be refreshed or if the form submission were to fail (not all fields are filled out, some have wrong data, etc.), but I can’t figure out how to do it. I tried looking this up, but nothing I do work.

Page with the form (with the fields I didn’t touch yet removed, only “doctor” has been changed for this functionality), hospitalForm.php:

JavaScript

PHP that processed the form data, hospitalForm.inc.php:

JavaScript

Edit: session_start() is called in header.php

Advertisement

Answer

Here are the final versions of the files in question: hospitalForm.php

JavaScript

hospitalForm.inc.php

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement