Results 1 to 7 of 7

Thread: PHP form to txt

  1. #1
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question PHP form to txt

    I have been using frontpage to build a social network .
    i need a status code. So far i load a txt file from the server and display it as current status. I need a way for users to edit this txt file(there will be one for each user) from a php form. i tried it in frontpage but i need frontpage ser
    er extensions which are discontinued.


    to make it clearer i need a form with a submit button that edits a .txt file on the server. the website isnt live yet so i dont have a set domain name

  2. #2
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i tried this, no luck need server exstensions
    PHP Code:
    <form>

    </
    form>
    <
    form method="POST" action="--WEBBOT-SELF--">
      <!--
    webbot bot="SaveResults" U-File="_private/form_results.txt"
      
    S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
      <
    p><input type="text" name="T1" size="20"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
    </
    form

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    That is all your code? I dont use frontpage/ know how it works but I think it'll be easier to just do it all with PHP. Are you using a version of php =>5?
    Corrections to my coding/thoughts welcome.

  4. The Following User Says Thank You to bluewalrus For This Useful Post:

    BMANrules (03-12-2011)

  5. #4
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default reply

    do you know the php code
    i need a form aswell as this not just save to file a form included in the code which users can type in thanks for quick reply

  6. #5
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    I know what you'd want to use it depends how much control you want the user to have though....

    http://php.net/manual/en/function.file-get-contents.php
    http://www.php.net/manual/en/functio...t-contents.php
    http://us3.php.net/manual/en/function.strip-tags.php

    So you use the get contents and then echo the contents into a textarea. Your probably going to want this to be controlled by a wysiwyg editor.

    http://en.wikipedia.org/wiki/CKEditor
    http://en.wikipedia.org/wiki/TinyMCE
    http://tinymce.moxiecode.com/
    http://ckeditor.com/

    You'll then want to save the contents once the user submits the new form with the put contents. You dont want to allow all tags in their input if it's being displayed to other users. If you don't have HTML content in the text file you wont need the wysiwyg but then there wont be much formatting with it. If you post the context of the text being inputted I can be more specific.
    Corrections to my coding/thoughts welcome.

  7. #6
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post

    Context:
    There will be a one line text box , a submit button and a reset button.
    The user enters text into the text box (like right now i'm ...) and presses submit.
    the text in the text box is saved to a form_results(1,2,3. one for each user).txt file. then when someone visits their page it loads the .txt file like this
    PHP Code:
    <p>Current Status:</p>
    <
    iframe name=my_frame src=LOCATION OF FILE/form_results.txt height=10width=20frameborder=0 scrolling=auto marginheight=5 marginwidth=5></iframe

  8. #7
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Not sure what you have there but a simple example would be

    PHP Code:
    <?php
    $file 
    "file.txt";
    if (!empty(
    $_POST['submitted'])) {
        
    $txt file_put_contents($filestrip_tags($_POST['file_contents']));
        echo 
    "File saved.";
        exit();
    }
    $txt file_get_contents($file);
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <textarea name="file_contents"><?php echo $txt;?></textarea>
    <input type="submit" name="submitted" />
    </form>
    Corrections to my coding/thoughts welcome.

Bookmarks

Posting Permissions

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