简体   繁体   English

存储没有 mysql 或 php 的用户输入

[英]store user input without mysql or php

I have a simple html application which displays words on a click of a next button.我有一个简单的 html 应用程序,单击下一步按钮即可显示单词。 It fetches the words from a javascript object literal file.它从 javascript object 文字文件中获取单词。 I want to mark some of the words as easy and some as difficult.我想将一些单词标记为简单,而将一些单词标记为困难。 How do I save this data from browser without using a mysql database?如何在不使用 mysql 数据库的情况下从浏览器中保存这些数据? can I edit the javascript object file directly from bowser?我可以直接从 Bowser 编辑 javascript object 文件吗?

If you want to take user input and store it permanently on your site, you'll have to employ some sort of server-side scripting.如果您想获取用户输入并将其永久存储在您的站点上,您将不得不使用某种服务器端脚本。 This doesn't have to be PHP, but it's probably the simplest way to do it.这不一定是 PHP,但这可能是最简单的方法。 You can't use client-side javascript to write to a remote file directly.您不能使用客户端 javascript 直接写入远程文件。

If I understand correctly, you have JS object/array with words, you're modifying it and want to store it modified version permanently.如果我理解正确,您有带有单词的 JS 对象/数组,您正在修改它并希望永久存储修改后的版本。

If so, then you can use "HTML5" localStorage .如果是这样,那么您可以使用“HTML5” localStorage

This storage is per-browser.此存储是每个浏览器的。 If you want to have single version shared between many users/browsers, then you will need some server-side support.如果您想在多个用户/浏览器之间共享单个版本,那么您将需要一些服务器端支持。

To save it on the client-side you could use cookies or local storage on supported browsers but this may not be the best approach if there are many words to keep track of.要将其保存在客户端,您可以使用 cookies 或支持的浏览器上的本地存储,但如果要跟踪很多单词,这可能不是最佳方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM