Reputation: 198
I am using Trisquel 7.0. I've some basic knowledge about html and JavaScript. Now I want to save html form data to file (Also interested in loading/filling html form from file).
I searched and found that This would be possible with php etc. But I don't know How to. As a beginner at this time, I would like to save only text information in text-file simply from html form.
Below I am writing simple example with simple html form and JavaScript function (without any action)
<html>
<form name=myform>
<input type=text name=mytext>
<input type=button value=save onClick=saving()>
</form>
<script>
function saving()
{
}
</script>
</html>
Now I want to save text from mytext
to text-file file, say mytext.txt
. All data/files are accessed locally on my PC. So, How can I do that? With PHP or JavaScript?; then How? (give me some basic script/information).
Also Suggest me external resource for learning interaction html form with database.
Upvotes: 2
Views: 76304
Reputation: 663
To save data without database or backend, you can services that provide just that. 1. PageClip 2. Usebasin 3. FormKeep 4. netlify 5. Formcarry
Follow this blog link to see details http://rohitvinay.com/how-to-store-contact-form-data-without-backend/
Upvotes: 0
Reputation: 3363
If you want to save the form data on the server side, I would do it with php like this:
<?php
$action = $_GET["action"];
$myText = $_POST["mytext"];
if($action = "save") {
$targetFolder = "/path/to/folder";
file_put_contents($targetFolder."mytext.txt", $myText);
}
?>
<html>
<head>
<title>myform</title>
</head>
<body>
<form action="?action=save" name="myform" method="post">
<input type=text name="mytext">
<input type="submit" value="save">
</form>
</body>
</html>
However if you want to save the data on the client side, normally you do it with local storage. But mind that only the client can access data of his local storage. Here is an example: Storing Objects in HTML5 localStorage
Upvotes: 8