I want to save the value entered in the text form on the web page to a text file so that I can use it later. How should it be done?

  • Answer # 1


    I would like to record what words were entered in the form and use them for ranking etc.

    For these applications, we recommend using adatabaserather than a text file. Since the website can be accessed at the same time, if you do notexclusive controlcorrectly, the data will be damaged, but if it is a database, exclusive control is also standard, so you can run without worry The

  • Answer # 2

    If you want to test before preparing the database,
    The following implementation is likely to be possible with just javascript.

    Download a text file (JSON.stringify or make a small CSV)

    Read file using FileReader in onchange event of input [type = file]

    In HTML, the operation form can be dynamically generated with javascript.

    Download button

    input [type = file] for reading files

    If you make it a library and read it with the script element, you can easily test it in similar cases.

    The question isUse later, so if you have a lot of test data input,
    Preparing the database on the server sideis certain, but I hope it will be helpful as a methodology.

  • Answer # 3


    For later use

    Isn't localstorage or cookies sufficient for reuse?
    What is the purpose of creating a text file?

    Server side

    Is it an image that each client keeps referring to on the server side?
    If you can use PHP

    File system functions PHP: file-Manual

    Please use

    Use this side for flow

    Read: fopen, fread, fclose

    Export: fopen, flock, fwrite, fclose

  • Answer # 4

    If you just want to reuse it
    I think that it is possible by GET or POST method of the form.