Alon M
Alon M

Reputation: 1683

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?

Upvotes: 0

Views: 155

Answers (1)

igor
igor

Reputation: 2916

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.

Upvotes: 1

Related Questions