Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default Write to a file?

    Does any one know how to write to a file?

    So once I click submit, it will replace the file with the new information?

    Edit:
    Dosnt matter, its easy
    <?php
    $File = "test.asx";
    $Handle = fopen($File, 'w');
    $Data = "Text";
    fwrite($Handle, $Data);
    print "Data Written";
    fclose($Handle);
    ?>
    Last edited by Moh; 28-03-2008 at 08:56 PM.

  2. #2
    Join Date
    Apr 2005
    Posts
    4,614
    Tokens
    90

    Latest Awards:

    Default

    PHP Code:
    <?php
    echo("Done");
    $data "ello"// Your data here
    $file "file.txt"// File url here chmod to 777
    $lol fopen("$file""w");
    if (!
    $lol) {
    echo(
    "ERROR");
    exit;
    }
    fputs ($lol,implode,("\n"));
    fwrite($lol,"$data");
    fclose($lol);
    ?>
    Last edited by Robbie; 28-03-2008 at 09:00 PM.

  3. #3
    Join Date
    Aug 2005
    Location
    London
    Posts
    9,773
    Tokens
    146

    Latest Awards:

    Default

    A basic and very badly coded one:
    PHP Code:
    <?php
    $text 
    $_POST['text'];
    $file fopen("log.txt","w+") or exit("The file could not be opened");
      
    fputs($file "$text");
      
    fclose($file);
    ?>
    You then will write a simple form to generate the text you want to put into the string to get changed in the log.txt file
    Code:
    <form method="post" action="log.php">
    <input type="text" name="text" />
    <input type="submit" name="submit" value="Update" />
    </form>
    And if wanted you can display the contents aswell:
    Code:
    <textarea>
    <?php echo file_get_contents("log.txt"); ?>
    </textarea>
    The log.txt file must be CHModed to 0777 .
    Last edited by --ss--; 28-03-2008 at 09:06 PM.

Posting Permissions

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