How to save the form data before form is submitted or printed?