You can save in session or cookies, for example. When a button is clicked, a request is sent to the handler script. Take them data from the required fields, for example, like this:
if(isset($_POST['name']) && !empty($_POST['name'])) { $_SESSION['input_name'] = $_POST['name']; }
And when loading the page:
$name = ""; if(!empty($_SESSION['input_name'])) { $name = $_SESSION['input_name']; }
Only the site is no longer in html, but in php. You can, of course, use the jquery-cookie library, save the data in the cookie with its help and also, when generating the page, check the presence of field contents in them, but using jquery means.