简体   繁体   中英

Save details on my server(txt file) from JavaScript

I have an HTML form page with some textboxes on it, which looks like this:

<tr style="padding:0 0 15px;">
  <td colspan="2"><br />
    <input type="checkbox" name="tipo" value="sr" />
    <label>MR.</label>
    <input type="checkbox" name="tipo2" value="sra" />
    <label>MRS.</label>
    <input type="checkbox" name="tipo2" value="srta" />
    <label>MS.</label>
    <input type="checkbox" name="tipo2" value="dr" />
    <label>DR.</label>
    <input type="checkbox" name="tipo2" value="prof" />
    <label>PROF.</label><br /><br />
  </td>
</tr>

All I really need to do is to save the data on my server (not on the client) in a Javascript/jQuery way and save it into a text file which will get updated with a new line everytime a client clicks on the send button.

Does anyone have a function to do it?

You need something like this on your server side

<?php
    $file = fopen('form.txt','a');
    fwrite($file,serialize($_REQUEST));
    fclose($file);
?>

Or you can enable support for PUT requests on your web server to upload files without server-side code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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