Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form data save in text file

    Hi,

    I want to save the form data (2 text box) in a text file (append) in one line on the server using html code.

    After save, it display the two texts has been added to the file.

    Need advice. thanks in advance.

    Thanks
    Sunil

  • #2
    New Coder
    Join Date
    Jan 2012
    Location
    RI, USA
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts
    HTML alone cannot do this - you will need to use either PHP or Javascript. The fwrite function in PHP can help you acheive this.

    PHP Code:
    $file "formData.txt";
    $handle fopen($formData'w') or die("Cannot open file - check write permissions!");
    $formData $_POST['fieldThatHasTheData'];
    fwrite($handle$formData);
    fclose($handle); 
    You would need a previous file that has the form data. I would certainly use post as the get method, although you could use get.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,634
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by Alternative View Post
    HTML alone cannot do this - you will need to use either PHP or Javascript.

    JavaScript can't do it either - you need a server side language such as PHP to do it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •