How can HTML text fields be filled using PHP to retain their values during page reload?

When a form is submitted and the page reloads, the values entered by the user in the text fields are usually lost. To retain these values, you can use PHP to populate the text fields with the submitted values. This can be achieved by checking if the form has been submitted and then using the `$_POST` superglobal array to retrieve the values and echo them back into the respective text fields.

<input type="text" name="username" value="<?php echo isset($_POST['username']) ? $_POST['username'] : ''; ?>">
<input type="text" name="email" value="<?php echo isset($_POST['email']) ? $_POST['email'] : ''; ?>">
<input type="submit" value="Submit">