+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
Web Development Thread, read from text box, append to file in Coding and Web Development; Im after a really simple php page, that will simply have a single text box, and a submit button, and ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200

    read from text box, append to file

    Im after a really simple php page, that will simply have a single text box, and a submit button, and basically just take the contents of the text box and append it to a file on the server...

    Anyone able to knock something up for me please?

  2. #2
    gibbo_ap's Avatar
    Join Date
    Nov 2007
    Location
    Staffs, UK
    Posts
    937
    Thank Post
    233
    Thanked 81 Times in 64 Posts
    Rep Power
    37
    what to you want it to save it to a text file or a db?

  3. #3

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    just a plaintext file, each entry on a new line..

  4. #4
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,096
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    Quote Originally Posted by RabbieBurns View Post
    Im after a really simple php page, that will simply have a single text box, and a submit button, and basically just take the contents of the text box and append it to a file on the server...

    Anyone able to knock something up for me please?
    I have exactly what you need but its asp and runs on ISA

    any good for you?

  5. Thanks to PEO from:

    RabbieBurns (16th October 2009)

  6. #5
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,096
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    except mine is save to an excel file, but each new entry is saved to a new line

  7. Thanks to PEO from:

    RabbieBurns (16th October 2009)

  8. #6
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,096
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    Ok I've modified it so it produces a txt file for you. Intrested?

  9. Thanks to PEO from:

    RabbieBurns (16th October 2009)

  10. #7

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    asp would be alright if i could get asp working on apache..

    also it needs to be plaintext on one line only as another script on the server is going to be reading the text file

  11. #8

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Just seen your post. Yeh I guess ASP would be alright, Ill just run it on one of my windows VMs..

    Cheers!

  12. #9
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,096
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    compling it all now 2 ticks

  13. Thanks to PEO from:

    RabbieBurns (16th October 2009)

  14. #10
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,096
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    here you go this should do for you, it will create a text file called results soon as you submit the form
    Attached Files Attached Files

  15. Thanks to PEO from:

    RabbieBurns (16th October 2009)

  16. #11

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,413
    Thank Post
    642
    Thanked 964 Times in 664 Posts
    Blog Entries
    2
    Rep Power
    327
    Thanks for remind me why I hate ASP

    In PHP...

    Code:
    <?php
    
    if(isset($_POST['content'])){
    
    	$filename = 'foo.txt';
    	$fhandle = fopen($filename, 'a');
    	fwrite($fhandle, $_POST['content'] . "\n");
    	fclose($fhandle);
    	echo 'File has probaly been written.';
    	
    } else {
    ?>
    
    	<form method="post">
    		<textarea name="content" rows="10" cols="50"></textarea><br />
    		<input type="submit" value="Save">
    	</form>
    	
    <?php
    }
    ?>

  17. Thanks to webman from:

    RabbieBurns (15th October 2009)

  18. #12

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Works almost, it appends
    Code:
    ,Submit
    to the end of each line though..

  19. #13

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    that last post was for PEO..

    Cheers webman, ill give that a go now

  20. #14

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,683
    Thank Post
    1,268
    Thanked 788 Times in 685 Posts
    Rep Power
    237
    Quote Originally Posted by RabbieBurns View Post
    Im after a really simple php page, that will simply have a single text box, and a submit button, and basically just take the contents of the text box and append it to a file on the server.
    Will more than one person be using it at a time? Like a class of 30 children? If so, watch out for race conditions when writing files - one user gets a handle on a file, then another user, they both think they are writing to the same point in the file and one users' data gets lost. This is why most modern web development is done with databases, as they ensure sequential writing of data.

    --
    David Hicks

  21. Thanks to dhicks from:

    RabbieBurns (16th October 2009)

  22. #15
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,096
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    check your permissions?

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Limit the number of characters in text box
    By MattCowen in forum Office Software
    Replies: 1
    Last Post: 21st September 2009, 04:57 PM
  2. edit/text box zoom utility
    By ajbritton in forum Windows
    Replies: 0
    Last Post: 13th February 2009, 11:26 AM
  3. Centering a scrolling text box in HTML
    By PWaite in forum Web Development
    Replies: 15
    Last Post: 19th January 2009, 09:53 AM
  4. EARTHQUAKE: READ TEXT FIRST, IT REALLY PUTS LIFE IN PERSPECTIVE
    By mattx in forum Jokes/Interweb Things
    Replies: 10
    Last Post: 28th February 2008, 09:46 AM
  5. Replies: 14
    Last Post: 12th September 2007, 10:13 AM

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
  •