Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Oct 2006
    Posts
    2,918
    Tokens
    946
    Habbo
    Verrou

    Latest Awards:

    Question Write info from a input form...

    Does anyone have the script to write the information from an input field to a .txt file when the submit button is pressed?

    I need it to insert a name with a proceeding comma.

    So the .txt file would look something like this:
    André,Frank,Bamaloo,Bob,Joe,Verrou

    Any help = +rep.

    Thanks,
    Ver.
    Quote Originally Posted by Special-1k View Post
    How do you uninstall an internet? I want to uninstall my Google Chrome and
    get firefox but I never really got rid of an internet my dad usually did it for me.
    If you know how post below so I can do this.

  2. #2
    Join Date
    Jun 2007
    Location
    Kilmarnock
    Posts
    3,227
    Tokens
    50

    Latest Awards:

    Default

    Search it up on google? Or go to websites that contain design codes etc.
    CPU i5 3570 @ 4.2 GHz | Mobo GigaByte Z77D3H | RAM 8GB | GPU AMD Radeon 6870 | OS Win 8 64-bit | HD 1TB HD and 128GB SSD | Wheel Logitech G27

  3. #3

    Default

    Not really sure but something like this probably..
    PHP Code:
    <?php
    if(isset($_POST['submit'])) // Forms submitted..
    {
        
    $field $_POST['field'];
        
    $file "yourfile.txt"//File you're wanting to write to
        
        
    file_put_contents($file$field);
        echo(
    "Inserted..");
    }
    else
    {
        echo(
    "<form method=\"post\">
        <input type=\"text\" name=\"field\" /><br />
        <input type=\"submit\" name=\"submit\" value=\"write\" />
        </form>"
    );
    }
    ?>
    make sure your txt file has write permissions.

  4. #4
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    PHP Code:
    <?php
    $text 
    "HIDER";
    $file fopen'text.txt''a' );
    $file fwrite$file$text );
    $file fclose$file );
    ?>
    Aint tested... Should work

  5. #5
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Blob View Post
    PHP Code:
    <?php
    $text 
    "HIDER";
    $file fopen'text.txt''a' );
    $file fwrite$file$text );
    $file fclose$file );
    ?>
    Aint tested... Should work
    Yep though it would probs be best to add a newline or space in to it, so there's some separation between the values

  6. #6
    Join Date
    Oct 2006
    Posts
    2,918
    Tokens
    946
    Habbo
    Verrou

    Latest Awards:

    Default

    JME, yours worked perfectly, thanks heaps.

    +rep to JME and blob.
    Quote Originally Posted by Special-1k View Post
    How do you uninstall an internet? I want to uninstall my Google Chrome and
    get firefox but I never really got rid of an internet my dad usually did it for me.
    If you know how post below so I can do this.

  7. #7
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    :S would JME's vers not rewrite the whole file every time?
    Coming and going...
    Highers are getting the better of me

  8. #8

    Default

    Quote Originally Posted by MrCraig View Post
    :S would JME's vers not rewrite the whole file every time?
    Ye it would, isn't that what he wanted? haha, idk, maybe i didn't understand what he was asking.

  9. #9
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    796
    Tokens
    0

    Default

    Quote Originally Posted by Jme View Post
    Not really sure but something like this probably..
    PHP Code:
    <?php
    if(isset($_POST['submit'])) // Forms submitted..
    {
        
    $field $_POST['field'];
        
    $file "yourfile.txt"//File you're wanting to write to
        
        
    file_put_contents($file$field);
        echo(
    "Inserted..");
    }
    else
    {
        echo(
    "<form method=\"post\">
        <input type=\"text\" name=\"field\" /><br />
        <input type=\"submit\" name=\"submit\" value=\"write\" />
        </form>"
    );
    }
    ?>
    make sure your txt file has write permissions.


    Yes uhhmm if i had test.php and used that insted of text.txt will that work
    Thanks,
    Chris
    Free Image Uploading

    __________________


    [/url]

    [/FONT]

  10. #10

    Default

    Quote Originally Posted by chrisgocrazyH View Post
    Yes uhhmm if i had test.php and used that insted of text.txt will that work
    No because that would create a syntax error.

Page 1 of 2 12 LastLast

Posting Permissions

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