Reputation: 51
In the DR Congo where internet is very expensive. I want to create an HTML form that can be completed offline and then submitted for PHP processing when online again. This would allow anyone to use any device or OS to work on their form offline saving money without needing anything more than a browser. Is it possible for client to click a button to save html form as an html file, complete it, and reopen completed form?
Upvotes: 3
Views: 4357
Reputation: 8546
You can enable offline behavior by specifying a cache manifest file:
See: http://fortuito.us/diveintohtml5/offline.html
Basically:
Change the html tag to reflect the location of the cache manifest file, e.g.:
<html manifest="/cache.manifest">
Create a text file, name it cache.manifest containing a list of all files necessary for offline functionality, for example:
CACHE MANIFEST
# rev 1
/static/main.css
/static/jquery.1.11.0.js
... etc
Every time you make changes to your app that affect offline behavior, increase the version number in line two of the file, e.g.
# rev 2
Configure your server so that the file is served with the text/cache-manifest MIME type
Upvotes: 0
Reputation: 357
You could download an HTML form and fill it out and save it locally using this answer: How to save data from a form with HTML5 Local Storage?
You would then have 2 buttons, one submit button to send it to the server and one save button to store the values locally.
In PHP, to download the form you would do something like this:-
<?
$file_name = 'form.html';
header('Content-disposition: attachment; filename=' . $file_name);
header('Content-type: text/html');
?>
Upvotes: 1