www.webdeveloper.com
Results 1 to 7 of 7

Thread: Can you write to .txt file fom html

  1. #1
    Join Date
    Dec 2005
    Posts
    3

    Can you write to .txt file fom html

    I hope this is not a stupid question. I have been looking all morning on how to do this and I can't seem to find much on it. Is it even possible. Can someone point me to a tutorial or anything, I should be able to adapt it to what I am doing. Thanks!

  2. #2
    Join Date
    Oct 2005
    Posts
    481
    You'll need a server side scripting language to do that. Does your host support php, asp or cgi?

  3. #3
    Join Date
    Dec 2005
    Posts
    3
    I am not sure. I tried to look into php a little and put this into the head section
    <?php
    function create_file($file){
    $fp = fopen($file, "a");//open file
    fwrite($fp, $Content);
    fclose($fp);//close file
    }//close function
    ?>
    but firefox gives an syntax error and points to the first line "<?php"
    Do I have to add something to make php readable? I know only so much about HTML and very little about php.

  4. #4
    Join Date
    Oct 2005
    Posts
    481
    Here's a tutorial on opening, reading and writing to text fiiles:

    http://codewalkers.com/tutorials/57/1.html

    Remember that the page must have the .php extension and the directory that contains the text file that you want to write to must have "write" permissions.

    All of this assumes that your host supports php.

    Also, this thread would be better in the php forum.

  5. #5
    Join Date
    Dec 2005
    Posts
    3
    Alright so my host doesn't support php. Maybe I am going about this the wrong way. I was trying to create like a little chat page. Real basic I type it and anyone on the page can read it and type back. Is there an easier way to do this? Thanks

  6. #6
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    If your host doesn't support server side languages then your only options are either to use a service provided by a third party or to move your hosting.
    Stephen

  7. #7
    Join Date
    Oct 2005
    Posts
    481
    Quote Originally Posted by Deez
    Alright so my host doesn't support php. Maybe I am going about this the wrong way. I was trying to create like a little chat page. Real basic I type it and anyone on the page can read it and type back. Is there an easier way to do this? Thanks
    May seem basic to you, but there's a lot going on behind the scenes. Maybe try multicity.com. They have a free version.

    Also, if you had a good hosting account, many of them provide chat scripts pre-installed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles